You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Editorial: refactor time zone identifier spec text (#3035)
This commit simplifies and clarifies spec text related to time zone
identifiers. Goals include making it easier to integrate Temporal
into ECMA-262 soon, and simplifying both Temporal and ECMA-402
spec text by centralizing common logic in ECMA-262.
If this commit is merged into ECMA-262, editorial PRs will follow for
Temporal (draft: tc39/proposal-temporal#2573)
and ECMA-402 (draft TBD).
Changes:
* Adds editorial spec text explaining how time zone identifiers work in
ECMAScript, and pointing readers to 402 for implementations that use
the IANA TimeZoneDatabase.
* Adds definitions related to time zone identifiers.
* Renames `DefaultTimeZone` to `SystemTimeZoneIdentifier` in order
to more clearly match its intent.
* Removes the need to override `SystemTimeZoneIdentifier` in ECMA-402.
* Renames variables named _timeZone_ to _timeZoneIdentifier_
to avoid future ambiguity with `Temporal.TimeZone`.
* Adds text that more clearly explains existing spec text allowing
non-402 implementations to support non-UTC time zones.
* Adds new abstract operation `AvailableNamedTimeZoneIdentifiers`
which, along with the existing (renamed) `SystemTimeZoneIdentifier`,
enables all ECMA-402 and Temporal operations related to time zone
identifiers to be implemented on top of these AOs.
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 0x0000 to 0x007F.
32166
+
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 IsTimeZoneOffsetString returns *true*.
32167
+
</p>
32168
+
<p>
32169
+
A <dfn variants="primary time zone identifiers">primary time zone identifier</dfn> is the preferred identifier for an available named time zone.
32170
+
A <dfn variants="non-primary time zone identifiers">non-primary time zone identifier</dfn> is an identifier for an available named time zone that is not a primary time zone identifier.
32171
+
An <dfn variants="available named time zone identifiers">available named time zone identifier</dfn> is either a primary time zone identifier or a non-primary time zone identifier.
32172
+
Each available named time zone identifier is associated with exactly one available named time zone.
32173
+
Each available named time zone is associated with exactly one primary time zone identifier and zero or more non-primary time zone identifiers.
32174
+
</p>
32175
+
<p>
32176
+
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.
32177
+
In addition, implementations may support any number of other available named time zones.
32178
+
</p>
32179
+
<p>
32180
+
Implementations that follow the requirements for time zones as described in the ECMA-402 Internationalization API specification are called <dfn>time zone aware</dfn>.
32181
+
Time zone aware implementations must support available named time zones corresponding to the Zone and Link names of the IANA Time Zone Database, and only such names.
32182
+
In time zone aware implementations, a primary time zone identifier is a Zone name, and a non-primary time zone identifier is a Link name, respectively, in the IANA Time Zone Database except as specifically overridden by AvailableNamedTimeZoneIdentifiers as specified in the ECMA-402 specification.
32183
+
Implementations that do not support the entire IANA Time Zone Database are still recommended to use IANA Time Zone Database names as identifiers to represent time zones.
<p>It is recommended that implementations use the time zone information of the IANA Time Zone Database <a href="https://www.iana.org/time-zones/">https://www.iana.org/time-zones/</a>.</p>
32220
+
<p>It is required for time zone aware implementations (and recommended for all others) to use the time zone information of the IANA Time Zone Database <a href="https://www.iana.org/time-zones/">https://www.iana.org/time-zones/</a>.</p>
32195
32221
<p>1:30 AM on 5 November 2017 in America/New_York is repeated twice, so GetNamedTimeZoneEpochNanoseconds(*"America/New_York"*, 2017, 11, 5, 1, 30, 0, 0, 0, 0) would return a List of length 2 in which the first element represents 05:30 UTC (corresponding with 01:30 US Eastern Daylight Time at UTC offset -04:00) and the second element represents 06:30 UTC (corresponding with 01:30 US Eastern Standard Time at UTC offset -05:00).</p>
32196
32222
<p>2:30 AM on 12 March 2017 in America/New_York does not exist, so GetNamedTimeZoneEpochNanoseconds(*"America/New_York"*, 2017, 3, 12, 2, 30, 0, 0, 0, 0) would return an empty List.</p>
<p>A <dfn variants="Time Zone Identifier Records">Time Zone Identifier Record</dfn> is a Record used to describe an available named time zone identifier and its corresponding primary time zone identifier.</p>
32249
+
<p>Time Zone Identifier Records have the fields listed in <emu-xref href="#table-time-zone-identifier-record-fields"></emu-xref>.</p>
32250
+
<emu-table id="table-time-zone-identifier-record-fields" caption="Time Zone Identifier Record Fields">
32251
+
<table>
32252
+
<tr>
32253
+
<th>Field Name</th>
32254
+
<th>Value</th>
32255
+
<th>Meaning</th>
32256
+
</tr>
32257
+
<tr>
32258
+
<td>[[Identifier]]</td>
32259
+
<td>a String</td>
32260
+
<td>An available named time zone identifier that is supported by the implementation.</td>
32261
+
</tr>
32262
+
<tr>
32263
+
<td>[[PrimaryIdentifier]]</td>
32264
+
<td>a String</td>
32265
+
<td>The primary time zone identifier that [[Identifier]] resolves to.</td>
32266
+
</tr>
32267
+
</table>
32268
+
</emu-table>
32269
+
<emu-note>
32270
+
<p>If [[Identifier]] is a primary time zone identifier, then [[Identifier]] is [[PrimaryIdentifier]].</p>
<h1>AvailableNamedTimeZoneIdentifiers ( ): a List of Time Zone Identifier Records</h1>
32222
32276
<dl class="header">
32223
32277
<dt>description</dt>
32224
-
<dd>It returns a String value representing the host environment's current time zone, which is either a String representing a UTC offset for which IsTimeZoneOffsetString returns *true*, or a String identifier accepted by GetNamedTimeZoneEpochNanoseconds and GetNamedTimeZoneOffsetNanoseconds.</dd>
32278
+
<dd>
32279
+
Its result describes all available named time zone identifiers in this implementation, as well as the primary time zone identifier corresponding to each available named time zone identifier.
32280
+
The List is ordered according to the [[Identifier]] field of each Time Zone Identifier Record.
32281
+
</dd>
32225
32282
</dl>
32283
+
<p>
32284
+
Time zone aware implementations, including all implementations that implement the ECMA-402 Internationalization API, must implement the AvailableNamedTimeZoneIdentifiers abstract operation as specified in the ECMA-402 specification.
32285
+
For implementations that are not time zone aware, AvailableNamedTimeZoneIdentifiers performs the following steps when called:
32286
+
</p>
32287
+
<emu-alg>
32288
+
1. If the implementation does not include local political rules for any time zones, then
32289
+
1. Return « the Time Zone Identifier Record { [[Identifier]]: *"UTC"*, [[PrimaryIdentifier]]: *"UTC"* } ».
32290
+
1. Let _identifiers_ be the List of unique available named time zone identifiers.
32291
+
1. [declared="comparefn"] Sort _identifiers_ into the same order as if an Array of the same values had been sorted using %Array.prototype.sort% with *undefined* as _comparefn_.
32292
+
1. Let _result_ be a new empty List.
32293
+
1. For each element _identifier_ of _identifiers_, do
32294
+
1. Let _primary_ be _identifier_.
32295
+
1. If _identifier_ is a non-primary time zone identifier in this implementation and _identifier_ is not *"UTC"*, then
32296
+
1. Set _primary_ to the primary time zone identifier associated with _identifier_.
32297
+
1. NOTE: An implementation may need to resolve _identifier_ iteratively to obtain the primary time zone identifier.
32298
+
1. Let _record_ be the Time Zone Identifier Record { [[Identifier]]: _identifier_, [[PrimaryIdentifier]]: _primary_ }.
32299
+
1. Append _record_ to _result_.
32300
+
1. Assert: _result_ contains a Time Zone Identifier Record _r_ such that _r_.[[Identifier]] is *"UTC"* and _r_.[[PrimaryIdentifier]] is *"UTC"*.
32301
+
1. Return _result_.
32302
+
</emu-alg>
32303
+
</emu-clause>
32226
32304
32227
-
<p>An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the DefaultTimeZone abstract operation as specified in the ECMA-402 specification.</p>
32228
-
<p>The default implementation of DefaultTimeZone, to be used for ECMAScript implementations that do not include local political rules for any time zones, performs the following steps when called:</p>
It returns a String representing the host environment's current time zone, which is either a String representing a UTC offset for which IsTimeZoneOffsetString returns *true*, or a primary time zone identifier.
32311
+
</dd>
32312
+
</dl>
32229
32313
32230
32314
<emu-alg>
32231
-
1. Return *"UTC"*.
32315
+
1. If the implementation only supports the UTC time zone, return *"UTC"*.
32316
+
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.
32317
+
1. If IsTimeZoneOffsetString(_systemTimeZoneString_) is *true*, return _systemTimeZoneString_.
32318
+
1. Return _systemTimeZoneString_.
32232
32319
</emu-alg>
32233
32320
32234
32321
<emu-note>
32235
32322
<p>
32236
-
To ensure the level of functionality that implementations commonly provide in the methods of the Date object, it is recommended that DefaultTimeZone return an IANA time zone name corresponding to the host environment's time zone setting, if such a thing exists.
32323
+
To ensure the level of functionality that implementations commonly provide in the methods of the Date object, it is recommended that SystemTimeZoneIdentifier return an IANA time zone name corresponding to the host environment's time zone setting, if such a thing exists.
32237
32324
GetNamedTimeZoneEpochNanoseconds and GetNamedTimeZoneOffsetNanoseconds must reflect the local political rules for standard time and daylight saving time in that time zone, if such rules exist.
32238
32325
</p>
32239
-
<p>For example, if the host environment is a browser on a system where the user has chosen US Eastern Time as their time zone, DefaultTimeZone returns *"America/New_York"*.</p>
32326
+
<p>For example, if the host environment is a browser on a system where the user has chosen US Eastern Time as their time zone, SystemTimeZoneIdentifier returns *"America/New_York"*.</p>
32240
32327
</emu-note>
32241
32328
</emu-clause>
32242
32329
@@ -32254,17 +32341,19 @@ <h1>
32254
32341
</dd>
32255
32342
</dl>
32256
32343
<emu-alg>
32257
-
1. Let _localTimeZone_ be DefaultTimeZone().
32258
-
1. If IsTimeZoneOffsetString(_localTimeZone_) is *true*, then
32259
-
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_localTimeZone_).
32344
+
1. Let _systemTimeZoneIdentifier_ be SystemTimeZoneIdentifier().
32345
+
1. If IsTimeZoneOffsetString(_systemTimeZoneIdentifier_) is *true*, then
32346
+
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_).
32260
32347
1. Else,
32261
-
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_localTimeZone_, ℤ(ℝ(_t_) × 10<sup>6</sup>)).
32348
+
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, ℤ(ℝ(_t_) × 10<sup>6</sup>)).
32262
32349
1. Let _offsetMs_ be truncate(_offsetNs_ / 10<sup>6</sup>).
32263
32350
1. Return _t_ + 𝔽(_offsetMs_).
32264
32351
</emu-alg>
32265
-
<p>If political rules for the local time _t_ are not available within the implementation, the result is _t_ because DefaultTimeZone returns *"UTC"* and GetNamedTimeZoneOffsetNanoseconds returns 0.</p>
32266
32352
<emu-note>
32267
-
<p>It is recommended that implementations use the time zone information of the IANA Time Zone Database <a href="https://www.iana.org/time-zones/">https://www.iana.org/time-zones/</a>.</p>
32353
+
<p>If political rules for the local time _t_ are not available within the implementation, the result is _t_ because SystemTimeZoneIdentifier returns *"UTC"* and GetNamedTimeZoneOffsetNanoseconds returns 0.</p>
32354
+
</emu-note>
32355
+
<emu-note>
32356
+
<p>It is required for time zone aware implementations (and recommended for all others) to use the time zone information of the IANA Time Zone Database <a href="https://www.iana.org/time-zones/">https://www.iana.org/time-zones/</a>.</p>
32268
32357
</emu-note>
32269
32358
<emu-note>
32270
32359
<p>Two different input time values <emu-eqn>_t_<sub>UTC</sub></emu-eqn> are converted to the same local time <emu-eqn>t<sub>local</sub></emu-eqn> at a negative time zone transition when there are repeated times (e.g. the daylight saving time ends or the time zone adjustment is decreased.).</p>
@@ -32286,19 +32375,19 @@ <h1>
32286
32375
</dd>
32287
32376
</dl>
32288
32377
<emu-alg>
32289
-
1. Let _localTimeZone_ be DefaultTimeZone().
32290
-
1. If IsTimeZoneOffsetString(_localTimeZone_) is *true*, then
32291
-
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_localTimeZone_).
32378
+
1. Let _systemTimeZoneIdentifier_ be SystemTimeZoneIdentifier().
32379
+
1. If IsTimeZoneOffsetString(_systemTimeZoneIdentifier_) is *true*, then
32380
+
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_).
32292
32381
1. Else,
32293
-
1. Let _possibleInstants_ be GetNamedTimeZoneEpochNanoseconds(_localTimeZone_, ℝ(YearFromTime(_t_)), ℝ(MonthFromTime(_t_)) + 1, ℝ(DateFromTime(_t_)), ℝ(HourFromTime(_t_)), ℝ(MinFromTime(_t_)), ℝ(SecFromTime(_t_)), ℝ(msFromTime(_t_)), 0, 0).
32382
+
1. Let _possibleInstants_ be GetNamedTimeZoneEpochNanoseconds(_systemTimeZoneIdentifier_, ℝ(YearFromTime(_t_)), ℝ(MonthFromTime(_t_)) + 1, ℝ(DateFromTime(_t_)), ℝ(HourFromTime(_t_)), ℝ(MinFromTime(_t_)), ℝ(SecFromTime(_t_)), ℝ(msFromTime(_t_)), 0, 0).
32294
32383
1. NOTE: The following steps ensure that when _t_ represents local time repeating multiple times at a negative time zone transition (e.g. when the daylight saving time ends or the time zone offset is decreased due to a time zone rule change) or skipped local time at a positive time zone transition (e.g. when the daylight saving time starts or the time zone offset is increased due to a time zone rule change), _t_ is interpreted using the time zone offset before the transition.
32295
32384
1. If _possibleInstants_ is not empty, then
32296
32385
1. Let _disambiguatedInstant_ be _possibleInstants_[0].
32297
32386
1. Else,
32298
32387
1. NOTE: _t_ represents a local time skipped at a positive time zone transition (e.g. due to daylight saving time starting or a time zone rule change increasing the UTC offset).
32299
-
1. [declared="tBefore"] Let _possibleInstantsBefore_ be GetNamedTimeZoneEpochNanoseconds(_localTimeZone_, ℝ(YearFromTime(_tBefore_)), ℝ(MonthFromTime(_tBefore_)) + 1, ℝ(DateFromTime(_tBefore_)), ℝ(HourFromTime(_tBefore_)), ℝ(MinFromTime(_tBefore_)), ℝ(SecFromTime(_tBefore_)), ℝ(msFromTime(_tBefore_)), 0, 0), where _tBefore_ is the largest integral Number < _t_ for which _possibleInstantsBefore_ is not empty (i.e., _tBefore_ represents the last local time before the transition).
32388
+
1. [declared="tBefore"] Let _possibleInstantsBefore_ be GetNamedTimeZoneEpochNanoseconds(_systemTimeZoneIdentifier_, ℝ(YearFromTime(_tBefore_)), ℝ(MonthFromTime(_tBefore_)) + 1, ℝ(DateFromTime(_tBefore_)), ℝ(HourFromTime(_tBefore_)), ℝ(MinFromTime(_tBefore_)), ℝ(SecFromTime(_tBefore_)), ℝ(msFromTime(_tBefore_)), 0, 0), where _tBefore_ is the largest integral Number < _t_ for which _possibleInstantsBefore_ is not empty (i.e., _tBefore_ represents the last local time before the transition).
32300
32389
1. Let _disambiguatedInstant_ be the last element of _possibleInstantsBefore_.
32301
-
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_localTimeZone_, _disambiguatedInstant_).
32390
+
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, _disambiguatedInstant_).
32302
32391
1. Let _offsetMs_ be truncate(_offsetNs_ / 10<sup>6</sup>).
32303
32392
1. Return _t_ - 𝔽(_offsetMs_).
32304
32393
</emu-alg>
@@ -32308,9 +32397,9 @@ <h1>
32308
32397
For example, the maximum time value is 8.64 × 10<sup>15</sup>, corresponding with *"+275760-09-13T00:00:00Z"*.
32309
32398
In an environment where the local time zone offset is ahead of UTC by 1 hour at that instant, it is represented by the larger input of 8.64 × 10<sup>15</sup> + 3.6 × 10<sup>6</sup>, corresponding with *"+275760-09-13T01:00:00+01:00"*.
32310
32399
</p>
32311
-
<p>If political rules for the local time _t_ are not available within the implementation, the result is _t_ because DefaultTimeZone returns *"UTC"* and GetNamedTimeZoneOffsetNanoseconds returns 0.</p>
32400
+
<p>If political rules for the local time _t_ are not available within the implementation, the result is _t_ because SystemTimeZoneIdentifier returns *"UTC"* and GetNamedTimeZoneOffsetNanoseconds returns 0.</p>
32312
32401
<emu-note>
32313
-
<p>It is recommended that implementations use the time zone information of the IANA Time Zone Database <a href="https://www.iana.org/time-zones/">https://www.iana.org/time-zones/</a>.</p>
32402
+
<p>It is required for time zone aware implementations (and recommended for all others) to use the time zone information of the IANA Time Zone Database <a href="https://www.iana.org/time-zones/">https://www.iana.org/time-zones/</a>.</p>
32314
32403
<p>
32315
32404
1:30 AM on 5 November 2017 in America/New_York is repeated twice (fall backward), but it must be interpreted as 1:30 AM UTC-04 instead of 1:30 AM UTC-05.
32316
32405
In UTC(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0)))), the value of _offsetMs_ is <emu-eqn>-4 × msPerHour</emu-eqn>.
@@ -33640,11 +33729,11 @@ <h1>
33640
33729
<dl class="header">
33641
33730
</dl>
33642
33731
<emu-alg>
33643
-
1. Let _localTimeZone_ be DefaultTimeZone().
33644
-
1. If IsTimeZoneOffsetString(_localTimeZone_) is *true*, then
33645
-
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_localTimeZone_).
33732
+
1. Let _systemTimeZoneIdentifier_ be SystemTimeZoneIdentifier().
33733
+
1. If IsTimeZoneOffsetString(_systemTimeZoneIdentifier_) is *true*, then
33734
+
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_).
33646
33735
1. Else,
33647
-
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_localTimeZone_, ℤ(ℝ(_tv_) × 10<sup>6</sup>)).
33736
+
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, ℤ(ℝ(_tv_) × 10<sup>6</sup>)).
33648
33737
1. Let _offset_ be 𝔽(truncate(_offsetNs_ / 10<sup>6</sup>)).
33649
33738
1. If _offset_ is *+0*<sub>𝔽</sub> or _offset_ > *+0*<sub>𝔽</sub>, then
0 commit comments