Description
openedon Jan 25, 2023
In InitializeDateTimeFormat step 30, if an Intl.DateTimeFormat
object is created without a timeZone
in its options argument, it'll use the current system time zone as retrieved from DefaultTimeZone. However, this value isn't guaranteed to remain consistent for the lifetime of the process. For example, the user may travel to a different part of the world and update their time zone, while any DateTimeFormat objects in running processes would continue to format according to their old time zone.
Essentially the question is, should an omitted timeZone
option mean:
- Create a formatter that formats in the current time zone as of the time of the object creation, or
- Create a formatter that formats in the current time zone as of the time of formatting?
This may pose a problem with Temporal.ZonedDateTime
in the future. Say, a web page from time to time updates a UI element using a cached formatter created with new Intl.DateTimeFormat(locale, { dateStyle: 'full', timeStyle: 'full' })
object, by formatting the result of Temporal.Now.zonedDateTime()
. If the user's time zone according to DefaultTimeZone changes, the ZonedDateTime's time zone and the formatter's time zone will no longer agree. In that case, the programmer would have to know not to cache the formatter object, which is not obvious.
I tested this with recent Firefox and Chromium, which both follow the spec.
Activity