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

Is JSTZ more reliable than Moment Timezone in detecting a user's timezone? #20

Open
rohit103 opened this issue Nov 30, 2018 · 3 comments

Comments

@rohit103
Copy link

Hi, can you please comment on how JSTZ compares to Moment timezone in detecting user's timezone? I will greatly appreciate if you can compare about the reliability, browser, and OS support.

Thank you for creating such a helpful resource!

@rohit103
Copy link
Author

I found the following at Moment's website. Do you have any information like the following for JSTZ? Thank you!

Moment Timezone uses the Internationalization API (Intl.DateTimeFormat().resolvedOptions().timeZone) in supported browsers to determine the user's time zone.

On other browsers, time zone detection is rather tricky to get right, as there is little information provided by those browsers. For those, it will use Date#getTimezoneOffset and Date#toString on a handful of moments around the current year to gather as much information about the browser environment as possible. It then compares that information with all the time zone data loaded and returns the closest match. In case of ties, the time zone with the city with largest population is returned.

@iansinnott
Copy link
Owner

What I remember is that at the time moment timezone did not support detection. Maybe I missed it in the docs, but that's why I originally forked this lib. If you're already using moment and it does support that functionality perhaps this lib is unnecessary.

As for your second comment you can check out the source where the internationalization API is used (if present) here: https://github.com/iansinnott/jstz/blob/master/jstz.main.js#L102

As for whether moment is more reliable... Probably. I suppose you would have to see how this lib stacks up to their test suite which is certainly much more extensive.

@rohit103
Copy link
Author

rohit103 commented Dec 1, 2018

Thank you @iansinnott for the prompt response and for making JSTZ!

On a different note, I will be sending you a note via an email soon. Best! Rohit

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