Skip to content

Commit

Permalink
Normative: fix SystemTimeZoneIdentifier offsets
Browse files Browse the repository at this point in the history
This commit adds a "normalized format of a time zone identifier"
definition, and uses it to ensure that SystemTimeZoneIdentifier only
returns normalized identifiers like "-05:00" (not "-0500" nor "-05")
or "America/Los_Angeles" (not "AMERICA/LOS_ANGELES" nor
"AmErIcA/lOs_AnGeLeS").

No current implementations return offset strings in non-normalized
format, so although this is a normative change, it won't break existing
ECMAScript code nor will it require changes to current implementations.

Fixes tc39#2584.
  • Loading branch information
justingrant committed Jul 1, 2023
1 parent 924b657 commit 6ac7d5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,9 @@ <h1>ISO 8601 grammar</h1>
UTCOffsetWithSubMinuteComponents[Extended] :
Sign Hour[+Padded] TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond Fraction?

NormalizedUTCOffset :
ASCIISign Hour[+Padded] `:` MinuteSecond

UTCOffsetMinutePrecision :
Sign Hour[+Padded]
Sign Hour[+Padded] TimeSeparator[+Extended] MinuteSecond
Expand Down
12 changes: 10 additions & 2 deletions spec/mainadditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ <h1>Time Zone Identifiers</h1>
<p>
Time zones in ECMAScript are represented by <dfn variants="time zone identifier">time zone identifiers</dfn>, which are Strings composed entirely of code units in the inclusive interval from <del>0x0000 to 0x007F</del><ins>0x0021 to 0x007E</ins>.
Time zones supported by an ECMAScript implementation may be <dfn variants="available named time zone">available named time zones</dfn>, represented by the [[Identifier]] field of the Time Zone Identifier Records returned by AvailableNamedTimeZoneIdentifiers, or <dfn variants="offset time zone">offset time zones</dfn>, represented by Strings for which <del>IsTimeZoneOffsetString</del><ins>IsOffsetTimeZoneIdentifier</ins> returns *true*.
<ins>Time zone identifiers are compared using ASCII-case-insensitive comparisons.</ins>
</p>
<p>
A <dfn variants="primary time zone identifiers">primary time zone identifier</dfn> is the preferred identifier for an available named time zone.
Expand All @@ -228,6 +227,15 @@ <h1>Time Zone Identifiers</h1>
Each available named time zone identifier is associated with exactly one available named time zone.
Each available named time zone is associated with exactly one primary time zone identifier and zero or more non-primary time zone identifiers.
</p>
<ins class="block">
<p>
Time zone identifiers are compared using ASCII-case-insensitive comparisons, and are accepted as input in any variation of letter case.
Offset time zone identifiers are compared using the number of minutes represented (not as a String), and are accepted as input in any the formats specified by |TimeZoneUTCOffsetName|.
However, ECMAScript built-in objects will only output the <dfn variants="time zone identifier in normalized format,normalized time zone identifier">normalized format of a time zone identifier</dfn>.
The normalized format of an available named time zone identifier is the preferred letter case for that identifier.
The normalized format of an offset time zone identifier is specified by |NormalizedUTCOffset|.
</p>
</ins>
<p>
ECMAScript implementations must support an available named time zone with the identifier *"UTC"*, which must be the primary time zone identifier for the UTC time zone.
In addition, implementations may support any number of other available named time zones.
Expand Down Expand Up @@ -283,7 +291,7 @@ <h1>SystemTimeZoneIdentifier ( ): a String</h1>

<emu-alg>
1. If the implementation only supports the UTC time zone, return *"UTC"*.
1. Let _systemTimeZoneString_ be the String representing the host environment's current time zone, either: a primary time zone identifier; or an offset time zone identifier.
1. Let _systemTimeZoneString_ be the String representing the host environment's current time zone, either a primary time zone identifier or an offset time zone identifier<ins>, as a time zone identifier in normalized format</ins>.
1. Return _systemTimeZoneString_.
</emu-alg>

Expand Down

0 comments on commit 6ac7d5f

Please sign in to comment.