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

Display the user's local IANA time zone by default, rather than just UTC offset #4

Open
gareth opened this issue Oct 7, 2022 · 0 comments

Comments

@gareth
Copy link

gareth commented Oct 7, 2022

At the moment, when rendering the initial page view, timezon.es uses moment.js to get and display the user's current offset from UTC:

timezon.es/src/ftz.js

Lines 426 to 428 in 7e375b5

_getCityName: function() {
return '<em>Browser local time</em> (UTC ' + this._ftz().moment().format('ZZ') + ')';
},

For all other cities added to the page, the IANA timezone from the tz database is displayed:

timezon.es/src/ftz.js

Lines 284 to 293 in 7e375b5

_getCityName: function() {
var city = this.city();
if (undefined === city) {
throw Error('This should not happen');
}
if (city.hasOwnProperty('description')) {
return '<em>' + city.name + ' - ' + city.description + '</em> (' + city.tz + ')';
}
return '<em>' + city.name + '</em> (' + city.tz + ')';
},

The javascript Internationalization API now exposes the browser/OS's timezone through an API which could be used to give a more consistent experience (the offset could still be used if this was unavailable for any reason).

> Intl.DateTimeFormat().resolvedOptions().timeZone
'Europe/London'
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

1 participant