Why doesn't Go use Windows's time zone data for time.LoadLocation?

307 views
Skip to first unread message

will....@gmail.com

unread,
Nov 27, 2024, 9:03:16 PM11/27/24
to golang-nuts
I read in a recent Go issue that Go uses time zone data in GOROOT for Windows and Plan 9. 

I looked through the Go proposal documents, but couldn't find one for the time package that had the original reasons, but I assume the reasons are because Windows didn't used to have IANA-compatible time zone info, and Plan 9 still doesn't.

Can anyone point me to info about why Go doesn't use the time zone info in the Windows registry instead? It looks like there is now a full mapping from IANA zones to Windows zones.

I'm also curious why Plan 9 doesn't include a tzdata or zoneinfo database file for programs to use for time zone logic/math, like most OSs, if anyone happens to know. I understand wanting to keep the system time simple, but the database still seems useful for generally doing math with times from different time zones. Why not just include it for programs?

Will

Jason E. Aten

unread,
Nov 29, 2024, 10:07:15 AM11/29/24
to golang-nuts
Hi Will!

For Windows, there is some context here https://github.com/golang/go/issues/21881

I think the short answer is that Windows does time zones differently enough that there would be subtle
bugs introduced, and only on Windows, if we tried to use the Windows info, and nobody wanted to 
volunteer to do the painstaking, long, slog of dealing with that, and in dealing with versions 
of windows might not have the needed data.

It is much simpler (and fewer bugs) if Go programs on all platforms are reading the same timezone data.
I for one prefer it that way.

That said, I'm sure if you wanted to go to the trouble of translating Windows timezone info into 
Go compatible timezone info, and/or teaching the Go runtime how to read timezone info from Windows, 
and providing a suitable fallback when Windows doesn't have it, then by all means. 

Since you will need the fallback anyway, I don't see it being worth the effort. 
I would always want the option to keep the timezone info consistent across 
all platforms; for my own sanity if nothing else.

Best,
Jason

Will Faught

unread,
Dec 1, 2024, 9:24:26 PM12/1/24
to Jason E. Aten, golang-nuts
Hi Jason!

Thanks, makes sense.

Will

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/ye9K3CSzbqI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/342a5f7d-724c-4fbc-ad65-59599756ec9fn%40googlegroups.com.

Oliver Lowe

unread,
Jan 13, 2025, 6:03:01 PMJan 13
to will....@gmail.com, golang-nuts

I'm also curious why Plan 9 doesn't include a tzdata or zoneinfo database
file for programs to use for time zone logic/math, like most OSs, if anyone
happens to know.

If I understand the question correctly, I think it does in the
/adm/timezone directory. Those files are in a format described in
ctime(2). Out of curiosity I read through the time package source
and found some logic to parse this data in zoneinfo_plan9.go.
initLocal is eventually called in zoneinfo.go.

Reply all
Reply to author
Forward
0 new messages