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: uninitialized time object produce unexpected conversion for trying to convert timezone with "func (t Time) In(loc *Location) Time" #8550
Comments
Something is funny in your example: it's using local mean time, not a proper time zone. I tried this in California and got t: 0001-01-01 00:00:00 +0000 UTC t in Local: 0000-12-31 16:00:00 -0800 PST which is what I would expect. Your result makes sense if you have no time zone data beyond LMT and you are in the middle of a time zone, as LMT is local mean time. I suspect the time zone data on the machine isn't right. |
The OS is OS X 10.9.4, and the timezone settings it set to auto timezone as per screenshot attachment. Attachments:
|
Doesn't matter if the time is initialized or not. What does 'go version' print?
What happened? package main
import (
"fmt"
"time"
)
func main() {
t, _ := time.Parse("20060102", "19000101")
fmt.Println("t:", t.String(), "t in Local:", t.In(time.Local).String())
}
On Linux Mint 17 Qiana, local time zone is Hong Kong (HKT) |
Note the reference time in time.Parse is wrong (should be "20060102"), @donlzx, your example is working as intended. It's because Hong Kong I think this issue is mostly due to the fact that some people are not aware I'm going to close this issue as working as intended. |
by nash.tsai:
The text was updated successfully, but these errors were encountered: