exposing system time zone

# David Herman (7 years ago)

This was brought up on Specifiction.

Does anyone know why it was left out of the first version of the Intl API? Just for lack of time? Is it planned for the next edition? Are there tricky issues around standardizing IANA time zones, or around incompatibilities between different OSes?

Interesting questions in that thread about what to do about time zone changes. An event for time zone changes seems important, but we don't currently have any precedent for standard library events in ECMAScript. Maybe that remains the purview of web APIs. But if we do expose the TZ via a standard API, it should have some way of dynamically querying the current TZ rather than just fixing the time zone at some random point in time.

# Domenic Denicola (7 years ago)

Interesting questions in that thread about what to do about time zone changes. An event for time zone changes seems important, but we don't currently have any precedent for standard library events in ECMAScript.

Object.observe change records? A synthetic change event seems perfect for this use case.

(Related, although not what I'm suggesting above: amasad.me/2014/03/16/why-im-excited-about-objectobserve "Evented Programming" header.)

# Andrew Paprocki (7 years ago)

On Tue, Jun 17, 2014 at 5:28 PM, David Herman <dherman at mozilla.com> wrote:

Does anyone know why it was left out of the first version of the Intl API? Just for lack of time? Is it planned for the next edition? Are there tricky issues around standardizing IANA time zones, or around incompatibilities between different OSes?

It might be related to the fact that the standard lib lets you craft your own timezone using standard notation and it does not have to correspond to a file in the IANA tzdata?

www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

(first 2 formats)

# David Herman (7 years ago)

On Jun 17, 2014, at 5:31 PM, Domenic Denicola <domenic at domenicdenicola.com> wrote:

Object.observe change records? A synthetic change event seems perfect for this use case.

I knew someone would suggest that. :)

Personally, I think that's pretty gross: it's encoding a real-world event (e.g. I moved into a different time zone) as a reflective object mutation event, rather than just building an API at a more intuitive level of abstraction. But I suppose if it works without having to actually standardize anything, then it just works.

# Andrea Giammarchi (7 years ago)

without reinventing the wheel or changing it, I think timezone is very close to geolocation so why not

navigator.geolocation.getTimeZone(*success*, *error*)

and

navigator.geolocation.watchTimeZone(*success*, *error*)

?

# Norbert Lindenberg (7 years ago)

On Jun 17, 2014, at 17:28 , David Herman <dherman at mozilla.com> wrote:

Does anyone know why it was left out of the first version of the Intl API? Just for lack of time? Is it planned for the next edition? Are there tricky issues around standardizing IANA time zones, or around incompatibilities between different OSes?

At the time we decided on the feature set for the first edition, Windows and IE did not support the IANA time zones. Microsoft agreed to support them for the second edition, and they are in the draft for that edition: norbertlindenberg.com/ecmascript/intl.html#sec-6.4

Interesting questions in that thread about what to do about time zone changes. An event for time zone changes seems important, but we don't currently have any precedent for standard library events in ECMAScript. Maybe that remains the purview of web APIs. But if we do expose the TZ via a standard API, it should have some way of dynamically querying the current TZ rather than just fixing the time zone at some random point in time.

We haven’t discussed how to handle time zone changes, and I don’t know whether all operating systems now provide notifications when the user changes the time zone. It seems this would also be an issue for the existing Date methods that use the local time zone.

# Mark S. Miller (7 years ago)

Even if the OS doesn't provide notifications, the implementation could poll in order to synthesize notifications. Given that the issue is time zone changes, the polling interval could be rather large without complaint, except from astronauts and east/west hyperloop travelers ;).

# Norbert Lindenberg (7 years ago)

The time zone the user wants to use, and therefore sets in the OS, is not always tied to the current location. For example, on a flight from San Francisco to Frankfurt I care about Pacific Time and Central European Time, but not the other time zones I fly over. There are also locations for which there is no well-defined mapping to a time zone, e.g., disputed border areas or regions where different population groups use different time zones.

# Mark S. Miller (7 years ago)

On Tue, Jun 17, 2014 at 7:27 PM, Norbert Lindenberg < ecmascript at lindenbergsoftware.com> wrote:

The time zone the user wants to use, and therefore sets in the OS, is not always tied to the current location. For example, on a flight from San Francisco to Frankfurt I care about Pacific Time and Central European Time, but not the other time zones I fly over. There are also locations for which there is no well-defined mapping to a time zone, e.g., disputed border areas or regions where different population groups use different time zones.

This same issue applies to geolocation and to absolute time. I want the computer to think it is where and when I tell it that it should think it is.

However, this does kill my observation that the polling could be very infrequent. There's no limit to the speed users can change their minds; especially since the "user" in question isn't necessarily human.

# Andrea Giammarchi (7 years ago)

This is upside down in my opinion ... Me, as a service, would like yo notify you based on where you are. You as a user with a specific timezone in mind can always ask for it explicitly ... I'm thinking about navigations based on your location, not something easy to polifill client side only via some Date instance. You know what i mean? Painfull either way, but more painful if i have to guess on JS side where the hack are you and what's the time in there, despite your OS based one. Maybe these two can coexist ?