-
Notifications
You must be signed in to change notification settings - Fork 18k
time: date conversion does not work when cross compiling for Linux #19123
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
The meaning of timezone abbreviations like "CET" are system dependent. The timezone database on your Windows system is giving it one meaning. The timezone database on your GNU/Linux system is giving it a different meaning or, rather, no meaning at all. This is documented in the Closing because I don't think there is anything to do here. |
I tried with the zoneinfo.zip file distributed with Go ( I've modified the code a bit to check if New test:
The program gives the following output:
|
If I use Code:
Output:
But that would mean I would have to manually get the timezone name from the time string, which is pretty much what you expect |
Ok, this makes
This finally gives the correct output:
|
Timezone abbreviations are basically broken by design. For example, you just used "EST", but "EST" means Eastern Standard Time in both the U.S. and Australia, although the two timezones are very different. There's really not a lot we can do to fix it. The only real solution is to avoid using timezone abbreviations. Stick to |
What bothers me about this is what feels like a broken implementation. I can successfully load the location manually using `time.LoadLocation` and use it in `time.ParseInLocation`, so why doesn't `time.Parse` do that automatically? Why is there a difference in behavior?
When it comes to choosing a different time zone format, I can't control it since it's comes from an outside source.
…On 17 feb. 2017 15:58 +0100, Ian Lance Taylor ***@***.***>, wrote:
Timezone abbreviations are basically broken by design. For example, you just used "EST", but "EST" means Eastern Standard Time in both the U.S. and Australia, although the two timezones are very different. There's really not a lot we can do to fix it. The only real solution is to avoid using timezone abbreviations. Stick to time.ParseInLocation or unambiguous numbers like -0500.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub (#19123 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AAI2D92VPt98Z0tOFIDsBGmA8nKGDiEAks5rdbWYgaJpZM4MDEi1).
|
I don't think there is a simple solution. If we try to look up the time zone in |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Conversion to UTC does not seem to work as expected on different platforms. The following program does not give the expected output when compiled for Linux:
The output when building for Windows (
GOOS=windows
) is this:But when compiling for Linux (
GOOS=linux
) I get this output instead:I tested the Linux binary in Ubuntu Bash for Windows, and on a Raspberry PI (built with GOARCH=arm). The result is the same on both platforms.
I've also tested it in the Golang Playground and it seems to be wrong there as well:
https://play.golang.org/p/kFvAJEx7dw
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: