Skip to content

Time.Format() local time zone in gopherjs does not match golang #923

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

Closed
nathanhack opened this issue Jun 2, 2019 · 2 comments
Closed

Time.Format() local time zone in gopherjs does not match golang #923

nathanhack opened this issue Jun 2, 2019 · 2 comments

Comments

@nathanhack
Copy link

Hi, I was using time and needed the short form of the time zone.
But it seems that gopherjs only does the long form.

What happened:
https://gopherjs.github.io/playground/#/8x_apJ2hLw

What I expected:
https://play.golang.org/p/6MlgfsMJ18W

I looked through the issues and I looked at the Gotchas but didn't see anything there. Maybe this is a known thing?

@flimzy
Copy link
Member

flimzy commented Jun 2, 2019

GopherJS doesn't have access to the full timezone database, due to space restrictions. See here for details and discussion: #64

@nathanhack
Copy link
Author

Thanks @flimzy,
I initially saw that but dismissed it thinking I was only interested in "local" (which gopherjs sort of supports). Which led me to finding JS's toLocaleString() I thought oh this is probably just a missing options in gopherjs because I could easily do the following in JS:

var event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
console.log(event.toLocaleString('default', { timeZoneName: 'short' }));
console.log(event.toLocaleString('default', { timeZoneName: 'long' }));

will output:

12/19/2012, 10:00:00 PM EST
12/19/2012, 10:00:00 PM Eastern Standard Time

But after looking at #64 in detail, I think my issue is related. :-(
Maybe I'll use goment (an pure golang implementation of moment.js mentioned in #64) instead.

@nathanhack nathanhack changed the title Time.Format() time zone in gopherjs does not match golang Time.Format() local time zone in gopherjs does not match golang Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants