Skip to content
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

Get current time zone #611

Open
krajcikondra opened this issue Jul 8, 2022 · 1 comment
Open

Get current time zone #611

krajcikondra opened this issue Jul 8, 2022 · 1 comment

Comments

@krajcikondra
Copy link

Hi,

I need to get name of current time zone. When I change time zone in google chrome Dev Tools -> click on three dots -> More Tools -> Sensors and change timezone to Tokyo. Check timezone in following script

const currentTimeZone = ZonedDateTime.now().zone(); 
console.log(currentTimeZone);

then I get following output:

ZoneRegion {_id: 'Europe/Prague', _rules: MomentZoneRules}

I expect "Asia\Tokyo" but I get "Europe/Prague".

Do am I something bad or is that bug?

Thanks in advance

@pithu
Copy link
Member

pithu commented Jul 9, 2022

Hi @krajcikondra , thanks for using js-joda and reporting this interesting issue.

The time we have been writing the code for detecting the system timezone, changing the timezone required a browser restart. Therefore timezone is detected only once at script startup time and not at runtime. Internally we are using Intl.DateTimeFormat().resolvedOptions().timeZone to determine zone info, so theoretically, with a little change in our code base, it should be possible to fix the issue.

I will mark the issue as an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants