-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-JSarch-wasmWebAssembly issuesWebAssembly issues
Milestone
Description
In time/zoneinfo_js.go the local timezone is determined by the UTC offset returned by the JS call:
(new Date()).getTimezoneOffset()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:
Intl.DateTimeFormat().resolvedOptions().timeZoneAs 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.
func initLocal() {
if intl := js.Global().Get("Intl"); !intl.IsUndefined() {
var err error
tz := js.Global().Get("Intl").Call("DateTimeFormat").Call("resolvedOptions").Get("timeZone").String()
Local, err = LoadLocation(tz)
if err == nil {
return
}
}
...zmwangxDemonZito
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-JSarch-wasmWebAssembly issuesWebAssembly issues