-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: js/wasm sets time.Local to a UTC offset instead of the actual timezone #44408
Comments
The internationalization API was the initial approach that was used. But then there was a bit of back and forth in the CL https://go-review.googlesource.com/c/go/+/143577 and it was decided to parse the timezone offset from cc @neelance |
I think the real issue here is that there was no https://golang.org/pkg/time/tzdata/ yet, so the wasm binary never shipped with any timezone data included. Calling Now that 6d63a74 added time/tzdata we could reconsider this. |
… date... due to DST. This is a bug in golang's wasm runtime itself: golang/go#44408, so we instead move the datetime handling to JS. And we introduce dayjs since even formatting a date as YYYY-MM-DD is a royal pain in JS, even in 2021...
… date... due to DST. This is a bug in golang's wasm runtime itself: golang/go#44408, so we instead move the datetime handling to JS. And we introduce dayjs since even formatting a date as YYYY-MM-DD is a royal pain in JS, even in 2021...
… date... due to DST. This is a bug in golang's wasm runtime itself: golang/go#44408, so we instead move the datetime handling to JS. And we introduce dayjs since even formatting a date as YYYY-MM-DD is a royal pain in JS, even in 2021...
if someone finds this for
|
… date... due to DST. This is a bug in golang's wasm runtime itself: golang/go#44408, so we instead move the datetime handling to JS. And we introduce dayjs since even formatting a date as YYYY-MM-DD is a royal pain in JS, even in 2021...
In
time/zoneinfo_js.go
the local timezone is determined by the UTC offset returned by the JS call:However
UTC offset != timezone
and this behaviour causes issues with displaying 'daylight savings' times. This behaviour is unexpected and undocumented and I would expect that time.Local is set to the JS environment's timezone (where available) instead of the current UTC offset.The timezone can be determined in JS with the Internationalization API:
As long as the tzdata package has been imported/embedded and the its init function runs first, adding the following code to the beginning of initLocal should (in theory) fix this issue.
The text was updated successfully, but these errors were encountered: