diff --git a/spec/abstractops.html b/spec/abstractops.html index 903898d91f..d120d79a17 100644 --- a/spec/abstractops.html +++ b/spec/abstractops.html @@ -1415,8 +1415,8 @@

ParseTemporalTimeZoneString ( _isoString_ )

1. Let _offsetNanoseconds_ be _sign_ × (((_hours_ × 60 + _minutes_) × 60 + _seconds_) × 109 + _nanoseconds_). 1. Let _offsetString_ be ! FormatTimeZoneOffsetString(_offsetNanoseconds_). 1. If _name_ is not *undefined*, then - 1. Assert: ! IsValidTimeZoneName(_name_) is *true*. - 1. Set _name_ to ! CanonicalizeTimeZoneName(_name_). + 1. Assert: ! HostIsValidTimeZoneName(_name_) is *true*. + 1. Set _name_ to ! HostCanonicalizeTimeZoneName(_name_). 1. Return the new Record: { [[Z]]: *undefined*, [[OffsetString]]: _offsetString_, diff --git a/spec/biblio.json b/spec/biblio.json index 364a44c02f..4d2793b415 100644 --- a/spec/biblio.json +++ b/spec/biblio.json @@ -1,5 +1,10 @@ { "https://tc39.es/ecma262/": [ + { + "type": "op", + "aoid": "CodePointsToString", + "id": "sec-codepointstostring" + }, { "type": "op", "aoid": "NumberToBigInt", @@ -15,11 +20,21 @@ "aoid": "RequireInternalSlot", "id": "sec-requireinternalslot" }, + { + "type": "op", + "aoid": "StringToCodePoints", + "id": "sec-stringtocodepoints" + }, { "type": "op", "aoid": "ToBigInt", "id": "sec-tobigint" }, + { + "type": "clause", + "number": "D.1", + "id": "sec-host-hooks-summary" + }, { "type": "term", "term": "%Date.now%", @@ -32,11 +47,6 @@ } ], "https://tc39.es/ecma402/": [ - { - "type": "op", - "aoid": "IsValidTimeZoneName", - "id": "sec-isvalidtimezonename" - }, { "type": "op", "aoid": "BasicFormatMatcher", @@ -52,16 +62,6 @@ "aoid": "CanonicalizeLocaleList", "id": "sec-canonicalizelocalelist" }, - { - "type": "op", - "aoid": "CanonicalizeTimeZoneName", - "id": "sec-canonicalizetimezonename" - }, - { - "type": "op", - "aoid": "DefaultTimeZone", - "id": "sec-defaulttimezone" - }, { "type": "op", "aoid": "FormatNumeric", diff --git a/spec/intl.html b/spec/intl.html index 649f3748d0..f2d4603f63 100644 --- a/spec/intl.html +++ b/spec/intl.html @@ -11,6 +11,70 @@

Amendments to the ECMAScript® 2021 Internationalization API Specification + +

Time Zone Names

+ + +

+ defines a set of host-defined abstract operations concerning the names of supported time zones. + This section introduces additional requirements on how ECMAScript hosts that are conforming implementations of the ECMAScript 2021 Internationalization API Specification may implement these operations. +

+
+ +

+ The ECMAScript 2021 Internationalization API Specification identifies time zones using the Zone and Link names of the IANA Time Zone Database. Their canonical form is the corresponding Zone name in the casing used in the IANA Time Zone Database. +

+ +

+ All registered Zone and Link names are allowed. Conforming implementations must recognize all 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. +

+ + +

HostIsValidTimeZoneName ( _timeZone_ )

+ +

+ The HostIsValidTimeZoneName is a host-defined abstract operation which verifies that the _timeZone_ argument (which must be a String value) represents a valid Zone or Link name of the IANA Time Zone Database. + A conforming implementation must implement the abstract operation as follows: +

+

+ The abstract operation returns true if _timeZone_, converted to upper case as described in , is equal to one of the Zone or Link names of the IANA Time Zone Database, converted to upper case as described in . It returns false otherwise. +

+
+ + +

HostCanonicalizeTimeZoneName ( _timeZone_ )

+ +

+ The HostCanonicalizeTimeZoneName is a host-defined abstract operation which returns the canonical and case-regularized form of the _timeZone_ argument (which must be a String value that is a valid time zone name as verified by the HostIsValidTimeZoneName abstract operation). + The following steps are taken: + A conforming implementation must implement the abstract operation as follows: +

+ + + 1. Assert: Type(_timeZone_) is String. + 1. Assert: ! HostIsValidTimeZoneName(_timeZone_) is *true*. + 1. Let _ianaTimeZone_ be the Zone or Link name of the IANA Time Zone Database such that _timeZone_, converted to upper case as described in , is equal to _ianaTimeZone_, converted to upper case as described in . + 1. If _ianaTimeZone_ is a Link name, let _ianaTimeZone_ be the corresponding Zone name as specified in the *"backward"* file of the IANA Time Zone Database. + 1. If _ianaTimeZone_ is *"Etc/UTC"* or *"Etc/GMT"*, return *"UTC"*. + 1. Return _ianaTimeZone_. + + +

+ The Intl.DateTimeFormat constructor allows this time zone name; if the time zone is not specified, the host environment's current time zone is used. Implementations shall support UTC and the host environment's current time zone returned from DefaultTimeZone (if different from UTC) in formatting. +

+
+ + + +

DefaultTimeZone ( )

+ +

+ The DefaultTimeZone abstract operation returns a String value representing the valid () and canonicalized () time zone name for the host environment's current time zone. +

+
+
+
+

Abstract Operations For DateTimeFormat Objects

@@ -133,9 +197,9 @@

InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )

1. Let _timeZone_ be DefaultTimeZone(). 1. Else, 1. Let _timeZone_ be ? ToString(_timeZone_). - 1. If the result of IsValidTimeZoneName(_timeZone_) is *false*, then + 1. If the result of ! HostIsValidTimeZoneName(_timeZone_) is *false*, then 1. Throw a *RangeError* exception. - 1. Let _timeZone_ be CanonicalizeTimeZoneName(_timeZone_). + 1. Let _timeZone_ be ! HostCanonicalizeTimeZoneName(_timeZone_). 1. Set _dateTimeFormat_.[[TimeZone]] to _timeZone_. 1. Let _opt_ be a new Record. 1. For each row of , except the header row, in table order, do diff --git a/spec/timezone.html b/spec/timezone.html index 55c28199a6..6abf150bd9 100644 --- a/spec/timezone.html +++ b/spec/timezone.html @@ -5,6 +5,97 @@

Temporal.TimeZone Objects

A Temporal.TimeZone object is an immutable Object referencing a time zone.

+ +

Time Zone Names

+ +

+ An ECMAScript implementation must support a number of built-in time zones. + At a minimum, implementations must support a built-in time zone named *"UTC"*. + If the return value of DefaultTimeZone is different from *"UTC"*, then implementations must support that time zone as a built-in time zone as well. + In addition, implementations may support any number of other built-in time zones. +

+

+ The `Temporal.TimeZone` constructor, when called with the name of a built-in time zone as the argument, will return a valid `Temporal.TimeZone` object. + When called with any other string, it will throw a *RangeError* exception. +

+

+ Implementations are encouraged to support the Zone and Link names of the IANA Time Zone Database, and to use the best available current and historical information about their offsets from UTC and their daylight saving time rules in calculations. +

+

+ An ECMAScript implementation that includes the ECMA-402 Internationalization API has additional requirements for the built-in time zones that must be supported, as specified in the ECMA-402 specification. +

+ + +

These host hooks need to be added to ES2021 when merged in.

+
+ + +

HostIsValidTimeZoneName ( _timeZone_ )

+ +

+ HostIsValidTimeZoneName is a host-defined abstract operation that takes argument _timeZone_ (a String value). + It verifies that _timeZone_ represents a valid built-in time zone. +

+

+ The implementation of HostIsValidTimeZoneName must conform to the following requirements: +

+
    +
  • It must always complete normally (i.e., not return an abrupt completion.)
  • +
  • It must always return either *true* or *false*.
  • +
+

+ The implementation of HostIsValidTimeZoneName should return *true* if _timeZone_, converted to upper case, is equal to one of the built-in time zone names, converted to upper case. + It should return *false* otherwise. +

+

The minimum implementation of HostIsValidTimeZoneName, supporting only the *"UTC"* time zone, performs the following steps when called: +

+ + + 1. Assert: Type(_timeZone_) is String. + 1. Let _tzText_ be ! StringToCodePoints(_timeZone_). + 1. Let _tzUpperText_ be the result of toUppercase(_tzText_), according to the Unicode Default Case Conversion algorithm. + 1. Let _tzUpper_ be ! CodePointsToString(_tzUpperText_). + 1. If _tzUpper_ and *"UTC"* are the same sequence of code points, return *true*. + 1. Return *false*. + +
+ + +

HostCanonicalizeTimeZoneName ( _timeZone_ )

+ +

+ HostCanonicalizeTimeZoneName is a host-defined abstract operation that takes argument _timeZone_ (a String value). + It returns the canonical and case-regularized form of the _timeZone_ argument. +

+

+ The _timeZone_ parameter must be a valid time zone name according to HostIsValidTimeZoneName. +

+

+ The implementation of HostCanonicalizeTimeZoneName must conform to the following requirements: +

+
    +
  • It must always complete normally (i.e., not return an abrupt completion.)
  • +
  • It must always return a String value.
  • +
+

The minimum implementation of HostCanonicalizeTimeZoneName, supporting only the *"UTC"* time zone, performs the following steps when called: +

+ + + 1. Assert: Type(_timeZone_) is String. + 1. Assert: ! HostIsValidTimeZoneName(_timeZone_) is *true*. + 1. Return *"UTC"*. + +
+ + +

DefaultTimeZone ( )

+ +

+ The DefaultTimeZone abstract operation returns a String value representing the valid () and canonicalized () time zone name for the host environment's current time zone. +

+
+
+

The Temporal.TimeZone Constructor

@@ -30,9 +121,9 @@

Temporal.TimeZone ( _identifier_ )

1. Let _offsetNanoseconds_ be ? ParseTimeZoneOffsetString(_identifier_). 1. Let _canonical_ be ? FormatTimeZoneOffsetString(_offsetNanoseconds_). 1. Else, - 1. If ! IsValidTimeZoneName(_id_) is *false*, then + 1. If ! HostIsValidTimeZoneName(_id_) is *false*, then 1. Throw a *RangeError* exception. - 1. Let _canonical_ be ! CanonicalizeTimeZoneName(_identifier_). + 1. Let _canonical_ be ! HostCanonicalizeTimeZoneName(_identifier_). 1. Return ? CreateTemporalTimeZone(_canonical_, NewTarget).
@@ -364,7 +455,7 @@

Abstract operations

CreateTemporalTimeZoneFromStatic ( _constructor_, _identifier_ )

- 1. Assert: ! IsValidTimeZoneName(_identifier_) is *true*. + 1. Assert: ! HostIsValidTimeZoneName(_identifier_) is *true*. 1. If ! IsConstructor(_constructor_) is *false*, throw a *TypeError* exception. 1. Let _result_ be ? Construct(_constructor_, « _identifier_ »). 1. Perform ? RequireInternalSlot(_result_, [[InitializedTemporalTimeZone]]). @@ -385,7 +476,7 @@

ParseTemporalTimeZone ( _string_ )

CreateTemporalTimeZone ( _identifier_ [ , _newTarget_ ] )

- 1. Assert: ! CanonicalizeTimeZoneName(_identifier_) is _identifier_. + 1. Assert: ! HostCanonicalizeTimeZoneName(_identifier_) is _identifier_. 1. If _newTarget_ is not given, set it to %Temporal.TimeZone%. 1. Let _object_ be ? OrdinaryCreateFromConstructor(_newTarget_, *"%Temporal.TimeZone.prototype%"*, « [[InitializedTemporalTimeZone]], [[Identifier]], [[OffsetNanoseconds]] »). 1. Set _object_.[[Identifier]] to _identifier_.