-
Notifications
You must be signed in to change notification settings - Fork 18k
time: inconsistent handling of CEST time zone #34913
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
Comments
( So I see (at least) two issues here:
|
Timezone parsing depends on the information recorded on your system. If you see different information on different systems, it's because they have different timezone information. On GNU/Linux this information is stored in /usr/share/zoneinfo. |
Thank you for picking up the issue.
|
Timezone parsing should only depend on the current system if not explicitly defined. |
Your example expects |
@bcmills 's point is that while In the tzdata database |
Change https://golang.org/cl/201197 mentions this issue: |
Correct. I agree. I still believe there's a problem with https://play.golang.org/p/xPnf-sz0E6W On Docker/Linux and Playground the output is
On Mac it is
What is confusing is that the same code behaves differently on Mac and Linux. Sorry for being a nag. |
In the tzdata database CEST is not recognized as a timezone name. It is used as the abbreviated name for daylight saving time in Central Europe. Avoid using CEST in documentation as it suggests that programs can parse dates that use CEST, which will typically fail on Unix systems. Updates #34913 Change-Id: I4b22f7d06607eb5b066812a48af58edd95498286 Reviewed-on: https://go-review.googlesource.com/c/go/+/201197 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
It is normal and expected for timezone parsing to differ on different systems, because it depends entirely on the timezone data present on the system. From the output you show it appears that your Mac has data for the |
I don't think there is anything to do here, so I'm going to close this issue. Please comment if you disagree. |
What version of Go are you using (
go version
)?Mac:
$ go version go1.13 darwin/amd64
Docker/Linux (image
golang:1.13.1
):$ go version go1.13.1 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?MAC
go env
OutputDocker/Linux
go env
OutputWhat did you do?
https://play.golang.org/p/mgNY9kKCUw6
pt, err := time.Parse("20060102 150405 MST", "20190906 062023 CEST")
expected := time.Date(2019, 9, 06, 04, 20, 23, 0, time.UTC)
diff := pt.Sub(expected)
The same absolute time created with different timezones should have 0 difference.
This works on Mac, but not on Docker/Linux.
What did you expect to see?
0s
duration as difference when subtracting the times.What did you see instead?
On go1.13 darwin/amd64 it works as expected, difference is
0s
durationOn go1.13.1 linux/amd64 the difference is
2h0m0s
durationThe text was updated successfully, but these errors were encountered: