Skip to content

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

Description

@gareth

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions