From 0907d10f26b953122b87b4879f88c31432fc1969 Mon Sep 17 00:00:00 2001
From: Philip Chimento
Date: Thu, 14 Apr 2022 16:03:21 -0700
Subject: [PATCH] Editorial: Define IsValidTimeZoneName in terms of
AvailableTimeZones
AvailableTimeZones is an abstract operation defined in the
Intl.Enumeration proposal (though there is a small difference, see below.)
Sharing AvailableTimeZones between ECMA-262 and ECMA-402 should allow us
to stipulate that if an implementation supports any time zone for
formatting in Intl.DateTimeFormat, it must support it for Temporal as
well.
This change means IsValidTimeZoneName is no longer implementation-defined,
and does not need to exist in ECMA-402, only in 262.
Note, this requires a slightly different algorithm for AvailableTimeZones
than the one in the Intl.Enumeration proposal. I have opened an issue for
resolving whether AvailableTimeZones should return only canonicalized
names or also backzone names:
https://github.com/tc39/proposal-intl-enumeration/issues/37
See: #541
See: #519
---
spec/abstractops.html | 2 +-
spec/intl.html | 51 +++++++++++++++++++++++++++++------------
spec/timezone.html | 39 +++++++++++++++++++++++--------
spec/zoneddatetime.html | 2 +-
4 files changed, 67 insertions(+), 27 deletions(-)
diff --git a/spec/abstractops.html b/spec/abstractops.html
index 17bd33ee7c..bb9d8e0979 100644
--- a/spec/abstractops.html
+++ b/spec/abstractops.html
@@ -497,7 +497,7 @@ ToRelativeTemporalObject ( _options_ )
1. Let _timeZoneName_ be _result_.[[TimeZoneIANAName]].
1. If _timeZoneName_ is not *undefined*, then
1. If ParseText(StringToCodePoints(_timeZoneName_), |TimeZoneNumericUTCOffset|) is a List of errors, then
- 1. If ! IsValidTimeZoneName(_timeZoneName_) is *false*, throw a *RangeError* exception.
+ 1. If IsValidTimeZoneName(_timeZoneName_) is *false*, throw a *RangeError* exception.
1. Set _timeZoneName_ to ! CanonicalizeTimeZoneName(_timeZoneName_).
1. Let _timeZone_ be ! CreateTemporalTimeZone(_timeZoneName_).
1. Else,
diff --git a/spec/intl.html b/spec/intl.html
index d053940373..e84de85021 100644
--- a/spec/intl.html
+++ b/spec/intl.html
@@ -32,22 +32,21 @@ Time Zone Names
A conforming implementation must recognize *"UTC"* and all other Zone and Link names (and only such names), and use best available current and historical information about their offsets from UTC and their daylight saving time rules in calculations. However, the set of combinations of time zone name and language tag for which localized time zone names are available is implementation dependent.
-
-
+
+
+
-
- This definition supersedes the definition provided in .
-
-
- The abstract operation IsValidTimeZoneName takes argument _timeZone_, a String value, and verifies that it represents a valid Zone or Link name of the IANA Time Zone Database.
-
+
+ The abstract operation IsValidTimeZoneName takes argument _timeZone_, a String value, and verifies that it represents a valid Zone or Link name of the IANA Time Zone Database.
+
-
- 1. If one of the Zone or Link names of the IANA Time Zone Database is an ASCII-case-insensitive match of _timeZone_, return *true*.
- 1. If _timeZone_ is an ASCII-case-insensitive match of *"UTC"*, return *true*.
- 1. Return *false*.
-
-
+
+ 1. If one of the Zone or Link names of the IANA Time Zone Database is an ASCII-case-insensitive match of _timeZone_, return *true*.
+ 1. If _timeZone_ is an ASCII-case-insensitive match of *"UTC"*, return *true*.
+ 1. Return *false*.
+
+
+
+
+
+
+ AvailableTimeZones (
+ ): a List of Strings
+
+
+
+ 1. Let _result_ be a List containing the String value of each Zone or Link name in the IANA Time Zone Database that is supported by the implementation.
+ 1. Sort _result_ in order as if an Array of the same values had been sorted using %Array.prototype.sort% using *undefined* as _comparefn_.
+ 1. Return _result_.
+
+
+ This definition supersedes the definition provided in .
+
+
+
Calendar Types
@@ -193,7 +214,7 @@ InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )
1. Set _timeZone_ to ! DefaultTimeZone().
1. Else,
1. Set _timeZone_ to ? ToString(_timeZone_).
- 1. If the result of ! IsValidTimeZoneName(_timeZone_) is *false*, then
+ 1. If the result of IsValidTimeZoneName(_timeZone_) is *false*, then
1. Throw a *RangeError* exception.
1. Set _timeZone_ to ! CanonicalizeTimeZoneName(_timeZone_).
1. Set _dateTimeFormat_.[[TimeZone]] to _timeZone_.
diff --git a/spec/timezone.html b/spec/timezone.html
index 7262ed9e96..4e55c50820 100644
--- a/spec/timezone.html
+++ b/spec/timezone.html
@@ -38,26 +38,23 @@ Time Zone Names
IsValidTimeZoneName (
_timeZone_: a String,
- )
+ ): a Boolean
-
- An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the IsValidTimeZoneName abstract operation as specified in the ECMA-402 specification.
-
Once IsValidTimeZoneName(_timeZone_) has returned *true*, for the lifetime of the surrounding agent, IsValidTimeZoneName(_variant_) must return *true* if _variant_ is an ASCII-case-insensitive match for either _timeZone_ or CanonicalizeTimeZoneName(_timeZone_).
For the purposes of this section, a String value _A_ is an ASCII-case-insensitive match for String value _B_ if the String value derived from _A_ by replacing each occurrence of a lowercase ASCII letter code unit (0x0061 through 0x007A, inclusive) with the corresponding uppercase ASCII letter code unit (0x0041 through 0x005A, inclusive) while preserving all other code units is exactly the same sequence of code units as the String value that is derived from _B_ in the same way.
- The minimum implementation of IsValidTimeZoneName for ECMAScript implementations that do not include the ECMA-402 API, supporting only the *"UTC"* time zone, performs the following steps when called:
-
- 1. If _timeZone_ is an ASCII-case-insensitive match for *"UTC"*, return *true*.
+ 1. Let _timeZones_ be AvailableTimeZones().
+ 1. For each String _candidate_ in _timeZones_, do
+ 1. If _timeZone_ is an ASCII-case-insensitive match for _candidate_, return *true*.
1. Return *false*.
@@ -106,6 +103,28 @@
1. Return *"UTC"*.
+
+
+
+ AvailableTimeZones (
+ ): a List of Strings
+
+
+
+
+ An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the AvailableTimeZones abstract operation as specified in the ECMA-402 specification.
+
+
+ The minimum implementation of AvailableTimeZones for ECMAScript implementations that do not include local political rules for any time zones, performs the following steps when called:
+
+
+
+ 1. Return « *"UTC"* ».
+
+
@@ -137,7 +156,7 @@ Temporal.TimeZone ( _identifier_ )
1. Set _identifier_ to ? ToString(_identifier_).
1. Let _parseResult_ be ParseText(StringToCodePoints(_identifier_), |TimeZoneNumericUTCOffset|).
1. If _parseResult_ is a List of errors, then
- 1. If ! IsValidTimeZoneName(_identifier_) is *false*, then
+ 1. If IsValidTimeZoneName(_identifier_) is *false*, then
1. Throw a *RangeError* exception.
1. Set _identifier_ to ! CanonicalizeTimeZoneName(_identifier_).
1. Return ? CreateTemporalTimeZone(_identifier_, NewTarget).
@@ -623,7 +642,7 @@ ToTemporalTimeZone ( _temporalTimeZoneLike_ )
1. If ParseText(StringToCodePoints(_parseResult_.[[Name]], |TimeZoneNumericUTCOffset|)) is not a List of errors, then
1. If _parseResult_.[[OffsetString]] is not *undefined*, and ! ParseTimeZoneOffsetString(_parseResult_.[[OffsetString]]) ≠ ! ParseTimeZoneOffsetString(_parseResult_.[[Name]]), throw a *RangeError* exception.
1. Else,
- 1. If ! IsValidTimeZoneName(_parseResult_.[[Name]]) is *false*, throw a *RangeError* exception.
+ 1. If IsValidTimeZoneName(_parseResult_.[[Name]]) is *false*, throw a *RangeError* exception.
1. Return ! CreateTemporalTimeZone(! CanonicalizeTimeZoneName(_parseResult_.[[Name]])).
1. If _parseResult_.[[Z]] is *true*, return ! CreateTemporalTimeZone(*"UTC"*).
1. Return ! CreateTemporalTimeZone(_parseResult_.[[OffsetString]]).
diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html
index fc43d73366..c9d973f763 100644
--- a/spec/zoneddatetime.html
+++ b/spec/zoneddatetime.html
@@ -1123,7 +1123,7 @@
1. Let _timeZoneName_ be _result_.[[TimeZoneName]].
1. Assert: _timeZoneName_ is not *undefined*.
1. If ParseText(StringToCodePoints(_timeZoneName_), |TimeZoneNumericUTCOffset|) is a List of errors, then
- 1. If ! IsValidTimeZoneName(_timeZoneName_) is *false*, throw a *RangeError* exception.
+ 1. If IsValidTimeZoneName(_timeZoneName_) is *false*, throw a *RangeError* exception.
1. Set _timeZoneName_ to ! CanonicalizeTimeZoneName(_timeZoneName_).
1. Let _offsetString_ be _result_.[[TimeZoneOffsetString]].
1. If _result_.[[TimeZoneZ]] is *true*, then