Skip to content

Existing DateTimeFormat objects don't reflect changes in the system time zone #750

Closed as not planned

Description

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:

  1. Create a formatter that formats in the current time zone as of the time of the object creation, or
  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions