-
Notifications
You must be signed in to change notification settings - Fork 18k
time: On Windows, zone name returned by Zone() method sometimes cannot be used in time.LoadLocation #5909
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
Labels
Comments
We think this might be the same cause: I'm in Vietnam, and when I call zonename, offset := time.Now().In(time.Local()).Zone() I get a zone-name "ICT" (Indo-China Time) When I then call time.LoadLocation("ICT") It returns UTC and the error: "unknown time zone ICT" I'm on a Mac (go 1.1), so not just a windows problem if it's the same bug, |
I think time.LoadLocation ( http://golang.org/pkg/time/#LoadLocation ) takes zone names like "Asia/Bangkok" not zone abbreviations like "ICT". Alex |
It does, but that's because, instead of using the system for looking up zones, it uses a packaged zoneinfo database. The *real* problem is that, given its current behavior, the time package is unable to parse its own times, such as in `time.Parse("MST", time.Now().Format("MST"))`. |
Remy, As you described, it fails on linux too: # cat > main.go package main import "fmt" import "time" func main() { zone, offset := time.Now().In(time.Local).Zone() fmt.Println(zone, offset) if loc, err := time.LoadLocation(zone); err == nil { fmt.Println(loc) } else { fmt.Println(err) } } # export TZ='Asia/Kolkata' # go run main.go IST 19800 unknown time zone IST # Alex |
This still leaves the problem that time.Parse can't parse time strings generated by the time package itself, such as in `time.Parse("MST", time.Now().Format("MST"))`. Should I open a separate bug for that? Or is this another instance of https://golang.org/issue/3790 ? |
Code: http://play.golang.org/p/CmKvKRSzxi Output: Zone: "" -10800 Format: 2006-01-02T15:04:05Z07:00 2013-08-02T13:43:47-03:00 2013-08-02 13:43:47 -0300 -0300 Format: 02 Jan 06 15:04 MST 02 Aug 13 13:43 -0300 parsing time "02 Aug 13 13:43 -0300" as "02 Jan 06 15:04 MST": cannot parse "-0300" as "MST" Format: Monday, 02-Jan-06 15:04:05 MST Friday, 02-Aug-13 13:43:47 -0300 parsing time "Friday, 02-Aug-13 13:43:47 -0300" as "Monday, 02-Jan-06 15:04:05 MST": cannot parse "-0300" as "MST" Format: Mon, 02 Jan 2006 15:04:05 MST Fri, 02 Aug 2013 13:43:47 -0300 parsing time "Fri, 02 Aug 2013 13:43:47 -0300" as "Mon, 02 Jan 2006 15:04:05 MST": cannot parse "-0300" as "MST" Format: Mon Jan _2 15:04:05 MST 2006 Fri Aug 2 13:43:47 -0300 2013 parsing time "Fri Aug 2 13:43:47 -0300 2013" as "Mon Jan _2 15:04:05 MST 2006": cannot parse "-0300 2013" as "MST" I changed my system language to Japanese and I don't get "ESAST" as the timezone abbreviation anymore (I presume the abbreviation code just sees a bunch of non-[A-Z] characters and ignores them all); however "ESAST" was it when windows was in English, presumably from "E. South America Standard Time" (http://msdn.microsoft.com/en-us/library/ms912391%28v=winembedded.11%29.aspx index 065). Output (system language English): Zone: "ESAST" -10800 Format: 2006-01-02T15:04:05Z07:00 2013-08-02T13:54:17-03:00 2013-08-02 13:54:17 -0300 ESAST Format: 02 Jan 06 15:04 MST 02 Aug 13 13:54 ESAST parsing time "02 Aug 13 13:54 ESAST" as "02 Jan 06 15:04 MST": cannot parse "ESAST" as "MST" Format: Monday, 02-Jan-06 15:04:05 MST Friday, 02-Aug-13 13:54:17 ESAST parsing time "Friday, 02-Aug-13 13:54:17 ESAST" as "Monday, 02-Jan-06 15:04:05 MST": cannot parse "ESAST" as "MST" Format: Mon, 02 Jan 2006 15:04:05 MST Fri, 02 Aug 2013 13:54:17 ESAST parsing time "Fri, 02 Aug 2013 13:54:17 ESAST" as "Mon, 02 Jan 2006 15:04:05 MST": cannot parse "ESAST" as "MST" Format: Mon Jan _2 15:04:05 MST 2006 Fri Aug 2 13:54:17 ESAST 2013 parsing time "Fri Aug 2 13:54:17 ESAST 2013" as "Mon Jan _2 15:04:05 MST 2006": cannot parse "ESAST 2013" as "MST" |
diogomfranco, Like this https://golang.org/issue/5783 ? Alex |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by diogomfranco:
The text was updated successfully, but these errors were encountered: