-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time: incorrect timezone for dates after 2038 #36654
Comments
This is happening because the time package does not consider the "extended" information that is available in the tzdata database. |
Change https://golang.org/cl/215539 mentions this issue: |
2038 support is becoming more and more important, we only have 18 left years to get it right now. Already some future dates will start to fail. So I'm glad to see this is being fixed. |
But note that this particular fix, while worth doing, is somewhat speculative. We don't actually know what the daylight savings time transitions will be in 2038, and so reporting future times as PDT or PST is a guess. Since this particular example uses |
Well, at least it should report a correct ("as of known today") time zone, and I understood your patch correctly, it does fix that. What I kind of did not understand - will that code addition of extended tz info parsing slow down all time-related ops, or this happens "once" and that's it? |
In the CL that I sent, it will slow down all timezone operations that involve dates in 2038 and later. It will not affect timezone operations for current dates. My guess is that before 2038 the tzdata format will change to push the slowdown farther into the future. Anyhow, since nobody has complained about this until now, I assume that not too many people care about it, so let's start by getting it right, and only then worry about making it fast. (My hope is that by 2038 we'll all stop using daylight savings time, and all of this code will become a peculiar historical artifact.) |
The CL does not seem restricted to US time zones. Regarding European time (EU), the trend is to discontinue Daylight Saving Time in the coming years (cf. https://ec.europa.eu/transport/themes/summertime_en) although final decision does not seem available. |
As @ianlancetaylor points out, this is an inherent problem with trying to report future civil times. There is nothing to prevent the relevant authorities from changing the laws back and forth, potentially on multiple occasions. Technically some jurisdictions could even enact law that retroactively changes the interpretation of past times.... (Weirder things have happened. The tzdata files make fascinating reading.) More prosaically, the tzdata files can be updated or corrected post-facto. In general, any attempt to make non-trivial use of a future civil time is fraught with difficulty. Making a best guess in displaying it is about as far as one should probably go. |
Change https://golang.org/cl/264302 mentions this issue: |
Looking at the internals of the TZ data being parsed, DST transition data being parsed by Go for this timezone appears to end ~2008 in the 1.14.2 release of Go EDIT: Confirmed the same behaviour in Go 1.15.3 releases with Alpine (which now provides 2020c version of tzdata). Buster does not present the same issue, but currently uses the 2020a tzdata, which was fine under Alpine.
Alpine Output (incorrect):
Buster Output (correct):
|
This issues with |
…ne transitions This gives us better expected information for daylight savings time transitions in year 2038 and beyond. For #36654 For #42155 Change-Id: I5a39aed3c40b184e1d7bb7d6ce3aff5307c4c146 Reviewed-on: https://go-review.googlesource.com/c/go/+/215539 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> (cherry picked from commit b71eafb) Reviewed-on: https://go-review.googlesource.com/c/go/+/264302 Trust: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. See: https://play.golang.org/p/zhDzRup9BRP
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/zhDzRup9BRP
What did you expect to see?
This is behavior that has been produced by other time processing tools and libraries. For example:
What did you see instead?
The text was updated successfully, but these errors were encountered: