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: cannot find zone on Windows #3437
Labels
Comments
This would happen if (and I believe only if) syscall.GetTimeZoneInformation fails. Can you let us know what this program prints on your Windows system? package main import ( "fmt" "syscall" ) func main() { var i syscall.Timezoneinformation _, err := syscall.GetTimeZoneInformation(&i) if err != nil { fmt.Printf("ERR: %v\n", err) } else { fmt.Printf("TZI: %+v\n", i) } } Thanks. Labels changed: added priority-later, removed priority-triage. Status changed to WaitingForReply. |
The code you pasted prints this: TZI: {Bias:-330 StandardName:[73 110 100 105 97 32 83 116 97 110 100 97 114 100 32 84 105 109 101 0 0 0 0 0 0 0 0 0 0 0 0 0] StandardDate:{Year:0 Month:0 DayOfWeek:0 Day:0 Hour:0 Minute:0 Second:0 Milliseconds:0} StandardBias:0 DaylightName:[73 110 100 105 97 32 68 97 121 108 105 103 104 116 32 84 105 109 101 0 0 0 0 0 0 0 0 0 0 0 0 0] DaylightDate:{Year:0 Month:0 DayOfWeek:0 Day:0 Hour:0 Minute:0 Second:0 Milliseconds:0} DaylightBias:-60} |
Thanks. I was definitely expecting an error and not actual information. Strange. If you could indulge me in one more program, can you check whether printing time.Local.String() prints "UTC" or "Local"? If it prints "UTC" that will confirm that, somehow, syscall.GetTimeZoneInformation failed on startup even though it is working for you when called from main. If it prints "Local" then I will be even more confused. The zone information in your output looks completely reasonable: it says that the zone is at +5:30 and is named "India Standard Time", with no switch to daylight savings time. If presented with that information during initialization, it looks to me like package time would correctly be showing IST +5:30. If time.Local.String() prints "UTC" the question is why did the syscall fail during startup. If time.Local.String() prints "Local" the question is why did the init not record the results (or perhaps not run at all). If you would like to try to debug this, the relevant code is src/pkg/time/zoneinfo_windows.go's initLocal. You can't import fmt in that package, but you can use the built-in print. I would try adding these prints: func initLocal() { println("initLocal called") var i syscall.Timezoneinformation if _, err := syscall.GetTimeZoneInformation(&i); err != nil { println("GTZI failed:", err.Error()) localLoc.name = "UTC" return } println("GTZI success") initLocalFromTZI(&i) } and then 'go install time' and re-build and re-run your program that prints time.Now().Zone(). |
Thanks. time.Local().String() prints UTC. I added the code to zoneinfo_windows.go. Zone() still prints "UTC 0" time.Local().String() now prints: initLocal called GTZI success 2012-03-30 20:37:47.5652908 +0000 UTC so it appears that the syscall succeeds, but still gets the wrong time zone. |
I think we do not handle timezones with no DST properly. Here is proposed fix http://golang.org/cl/5967063/. Alex Labels changed: added os-windows, packagebug. Owner changed to @alexbrainman. Status changed to Started. |
This issue was closed by revision d3c92b7. Status changed to Fixed. |
Issue #3592 has been merged into this issue. |
Why time.Local.String() prints ""? call println(time.Now().In(time.Local).Zone()) output: CST 28800 call syscall.GetTimeZoneInformation got such as: syscall.Timezoneinformation{ StandardName: "中国标准时间", DaylightName: "中国夏令时", Bias: -480, StandardDate: syscall.Systemtime{ Year: 0x0, Month: 0x0, DayOfWeek: 0x0, Day: 0x0, Hour: 0x0, Minute: 0x0, Second: 0x0, Milliseconds: 0x0}, StandardBias: 0, DaylightDate: syscall.Systemtime{ Year: 0x0, Month: 0x0, DayOfWeek: 0x0, Day: 0x0, Hour: 0x0, Minute: 0x0, Second: 0x0, Milliseconds: 0x0, }, DaylightBias: -60, } OS: Windows 7 ultimate 64-bit (Intel) Go Version: go1.2 Compiler: 6g |
alexbrainman
added a commit
that referenced
this issue
May 11, 2015
…indows ««« backport 701af83040ac time: fix handling of locations with no dst on windows Fixes #3437. R=rsc CC=golang-dev https://golang.org/cl/5967063 »»»
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by sanat.gersappa:
The text was updated successfully, but these errors were encountered: