Amendments to the ECMAScript® 2023 Language Specification

This section lists amendments which must be made to ECMA-262, the ECMAScript® 2023 Language Specification, other than the addition of the new sections specifying the Temporal object and everything related to it. Text to be added is marked like this, and text to be deleted is marked like this. Blocks of unmodified text between modified sections are marked by [...].

The String Type

This section intends to move the definitions of ASCII-uppercase, ASCII-lowercase, and ASCII-case-insensitive match from ECMA-402 into ECMA-262, after the definition of the ASCII word characters.

[...]

The ASCII-uppercase of a String _S_ is the String derived from _S_ by replacing each occurrence of an ASCII lowercase letter code unit (0x0061 through 0x007A, inclusive) with the corresponding ASCII uppercase letter code unit (0x0041 through 0x005A, inclusive) while preserving all other code units.

The ASCII-lowercase of a String _S_ is the String derived from _S_ by replacing each occurrence of an ASCII uppercase letter code unit (0x0041 through 0x005A, inclusive) with the corresponding ASCII lowercase letter code unit (0x0061 through 0x007A, inclusive) while preserving all other code units.

A String _A_ is an ASCII-case-insensitive match for a String _B_ if the ASCII-lowercase of _A_ is the ASCII-lowercase of _B_.

The Year-Week Record Specification Type

The Year-Week Record specification type is returned by the week number calculation in ISOWeekOfYear, and the corresponding calculations for other calendars if applicable. It comprises a calendar week of year with the corresponding week calendar year.

Year-Week Records have the fields listed in table .

Year-Week Record Fields
Field Name Value Meaning
[[Week]] a positive integer or *undefined* The calendar week of year.
[[Year]] an integer or *undefined* The week calendar year.

Mathematical Operations

[...]

The notation “_x_ modulo _y_” (_y_ must be finite and non-zero) computes a value _k_ of the same sign as _y_ (or zero) such that abs(_k_) < abs(_y_) and _x_ - _k_ = _q_ × _y_ for some integer _q_.

The mathematical function remainder(_x_, _y_) produces the mathematical value whose sign is the sign of _x_ and whose magnitude is abs(_x_) modulo _y_.

[...]

Mathematical functions min, max, abs, remainder, floor, and truncate are not defined for Numbers and BigInts, and any usage of those methods that have non-mathematical value arguments would be an editorial error in this specification.

[...]

Abstract Operations

[...]

Operations for Reading Options

GetOptionsObject ( _options_: an ECMAScript language value, ): either a normal completion containing an Object or a throw completion

description
It returns an Object suitable for use with GetOption, either _options_ itself or a default empty Object. It throws a *TypeError* if _options_ is not *undefined* and not an Object.
1. If _options_ is *undefined*, then 1. Return OrdinaryObjectCreate(*null*). 1. If _options_ is an Object, then 1. Return _options_. 1. Throw a *TypeError* exception.

GetOption ( _options_: an Object, _property_: a property key, _type_: ~boolean~ or ~string~, _values_: ~empty~ or a List of ECMAScript language values, _default_: ~required~ or an ECMAScript language value, ): either a normal completion containing an ECMAScript language value or a throw completion

description
It extracts the value of the specified property of _options_, converts it to the required _type_, checks whether it is allowed by _values_ if _values_ is not ~empty~, and substitutes _default_ if the value is *undefined*.
1. Let _value_ be ? Get(_options_, _property_). 1. If _value_ is *undefined*, then 1. If _default_ is ~required~, throw a *RangeError* exception. 1. Return _default_. 1. If _type_ is ~boolean~, then 1. Set _value_ to ToBoolean(_value_). 1. Else, 1. Assert: _type_ is ~string~. 1. Set _value_ to ? ToString(_value_). 1. If _values_ is not ~empty~ and _values_ does not contain _value_, throw a *RangeError* exception. 1. Return _value_.

GetRoundingModeOption ( _options_: an Object, _fallback_: a rounding mode, ): either a normal completion containing a rounding mode, or a throw completion

description
It fetches and validates the *"roundingMode"* property from _options_, returning _fallback_ as a default if absent.
1. Let _allowedStrings_ be the List of Strings from the "String Identifier" column of . 1. Let _stringFallback_ be the value from the "String Identifier" column of the row with _fallback_ in its "Rounding Mode" column. 1. Let _stringValue_ be ? GetOption(_options_, *"roundingMode"*, ~string~, _allowedStrings_, _stringFallback_). 1. Return the value from the "Rounding Mode" column of the row with _stringValue_ in its "String Identifier" column.

A rounding mode is one of the values in the "Rounding Mode" column of . An unsigned rounding mode is one of the values in the "Unsigned Rounding Mode" column of .

The following table is taken from ECMA-402 () but with the addition of specification values.

Rounding modes
Rounding Mode String Identifier Description Examples: Round to 0 fraction digits
-1.5 0.4 0.5 0.6 1.5
~ceil~ *"ceil"* Toward positive infinity ⬆️ [-1] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
~floor~ *"floor"* Toward negative infinity ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
~expand~ *"expand"* Away from zero ⬇️ [-2] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
~trunc~ *"trunc"* Toward zero ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
~half-ceil~ *"halfCeil"* Ties toward positive infinity ⬆️ [-1] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
~half-floor~ *"halfFloor"* Ties toward negative infinity ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
~half-expand~ *"halfExpand"* Ties away from zero ⬇️ [-2] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
~half-trunc~ *"halfTrunc"* Ties toward zero ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
~half-even~ *"halfEven"* Ties toward an even rounding increment multiple ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬆️ [2]
The examples are illustrative of the unique behaviour of each option. ⬆️ means "resolves toward positive infinity"; ⬇️ means "resolves toward negative infinity".

GetRoundingIncrementOption ( _options_: an Object, ): either a normal completion containing a positive integer in the inclusive interval from 1 to 109, or a throw completion

description
It fetches and validates the *"roundingIncrement"* property from _options_, returning a default if absent.
1. Let _value_ be ? Get(_options_, *"roundingIncrement"*). 1. If _value_ is *undefined*, return *1*𝔽. 1. Let _integerIncrement_ be ? ToIntegerWithTruncation(_value_). 1. If _integerIncrement_ < 1 or _integerIncrement_ > 109, throw a *RangeError* exception. 1. Return _integerIncrement_.

Overview of Date Objects and Definitions of Abstract Operations

[...]

GetUTCEpochNanoseconds ( _year_: an integer, _month_: an integer in the inclusive interval from 1 to 12, _day_: an integer in the inclusive interval from 1 to 31, _hour_: an integer in the inclusive interval from 0 to 23, _minute_: an integer in the inclusive interval from 0 to 59, _second_: an integer in the inclusive interval from 0 to 59, _millisecond_: an integer in the inclusive interval from 0 to 999, _microsecond_: an integer in the inclusive interval from 0 to 999, _nanosecond_: an integer in the inclusive interval from 0 to 999, _isoDateTime_: an ISO Date-Time Record, ): a BigInt

description
The returned value represents a number of nanoseconds since the epoch that corresponds to the given ISO 8601 calendar date and wall-clock time in UTC.
1. Let _date_ be MakeDay(𝔽(_year__isoDateTime_.[[ISODate]].[[Year]]), 𝔽(_month__isoDateTime_.[[ISODate]].[[Month]] - 1), 𝔽(_day__isoDateTime_.[[ISODate]].[[Day]])). 1. Let _time_ be MakeTime(𝔽(_hour__isoDateTime_.[[Time]].[[Hour]]), 𝔽(_minute__isoDateTime_.[[Time]].[[Minute]]), 𝔽(_second__isoDateTime_.[[Time]].[[Second]]), 𝔽(_millisecond__isoDateTime_.[[Time]].[[Millisecond]])). 1. Let _ms_ be MakeDate(_date_, _time_). 1. Assert: _ms_ is an integral Number. 1. Return ℤ(ℝ(_ms_) × 106 + _microsecond__isoDateTime_.[[Time]].[[Microsecond]] × 103 + _nanosecond__isoDateTime_.[[Time]].[[Nanosecond]]).

Time Zone Identifiers

Time zones in ECMAScript are represented by time zone identifiers, which are Strings composed entirely of code units in the inclusive interval from 0x0000 to 0x007F0x0021 to 0x007E. Time zones supported by an ECMAScript implementation may be available named time zones, represented by the [[Identifier]] field of the Time Zone Identifier Records returned by AvailableNamedTimeZoneIdentifiers, or offset time zones, represented by Strings for which IsTimeZoneOffsetStringIsOffsetTimeZoneIdentifier returns *true*.

A primary time zone identifier is the preferred identifier for an available named time zone. A non-primary time zone identifier is an identifier for an available named time zone that is not a primary time zone identifier. An available named time zone identifier is either a primary time zone identifier or a non-primary time zone identifier. 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.

An available time zone identifier is either an available named time zone identifier or an offset time zone identifier.

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 |UTCOffset[~SubMinutePrecision]|. However, ECMAScript built-in objects will only output the normalized format of a time zone identifier. 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| and produced by FormatOffsetTimeZoneIdentifier with _style_ either not present or set to ~separated~.

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.

Implementations that follow the requirements for time zones as described in the ECMA-402 Internationalization API specification are called time zone aware. 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. 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. 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.

GetNamedTimeZoneEpochNanoseconds ( _timeZoneIdentifier_: a String, _year_: an integer, _month_: an integer in the inclusive interval from 1 to 12, _day_: an integer in the inclusive interval from 1 to 31, _hour_: an integer in the inclusive interval from 0 to 23, _minute_: an integer in the inclusive interval from 0 to 59, _second_: an integer in the inclusive interval from 0 to 59, _millisecond_: an integer in the inclusive interval from 0 to 999, _microsecond_: an integer in the inclusive interval from 0 to 999, _nanosecond_: an integer in the inclusive interval from 0 to 999, _isoDateTime_: an ISO Date-Time Record, ): a List of BigInts

description
Each value in the returned List represents a number of nanoseconds since the epoch that corresponds to the given ISO 8601 calendar date and wall-clock time in the named time zone identified by _timeZoneIdentifier_.

When the input represents a local time occurring more than once because of a negative time zone transition (e.g. when daylight saving time ends or the time zone offset is decreased due to a time zone rule change), the returned List will have more than one element and will be sorted by ascending numerical value. When the input represents a local time skipped because of a positive time zone transition (e.g. when daylight saving time begins or the time zone offset is increased due to a time zone rule change), the returned List will be empty. Otherwise, the returned List will have one element.

The default implementation of GetNamedTimeZoneEpochNanoseconds, to be used for ECMAScript implementations that do not include local political rules for any time zones, performs the following steps when called:

1. Assert: _timeZoneIdentifier_ is *"UTC"*. 1. Let _epochNanoseconds_ be GetUTCEpochNanoseconds(_year_, _month_, _day_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond__isoDateTime_). 1. Return « _epochNanoseconds_ ».

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 https://www.iana.org/time-zones/.

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) for that time zone and ISO date-time 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).

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) for that time zone and ISO date-time would return an empty List.

SystemTimeZoneIdentifier ( ): an available time zone identifier

description
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 identifiera primary time zone identifier or an offset time zone identifier.
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 as a time zone identifier in normalized format, either a primary time zone identifier or an offset time zone identifier. 1. Return _systemTimeZoneString_.

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. GetNamedTimeZoneEpochNanoseconds and GetNamedTimeZoneOffsetNanoseconds must reflect the local political rules for standard time and daylight saving time in that time zone, if such rules exist.

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"*.

Time Zone Offset String FormatFormats

ECMAScript defines a string interchange format for UTC offsets, derived from ISO 8601. The format is described by the following grammar.

ECMAScript defines string interchange formats for UTC offsets, derived from ISO 8601. UTC offsets that represent offset time zone identifiers, or that are intended for interoperability with ISO 8601, use only hours and minutes and are specified by |UTCOffset[~SubMinutePrecision]|. UTC offsets that represent the offset of a named time zone can be more precise, and are specified by |UTCOffset[+SubMinutePrecision]|.

These formats are described by the ISO String grammar in .

[...]

The grammar in this section should be deleted; it is replaced by the ISO 8601 / RFC 9557 String grammar in .

LocalTime ( _t_: a finite time value, ): an integral Number

description
It converts _t_ from UTC to local time. The local political rules for standard time and daylight saving time in effect at _t_ should be used to determine the result in the way specified in this section.
1. Let _systemTimeZoneIdentifier_ be SystemTimeZoneIdentifier(). 1. Let _parseResult_ be ! ParseTimeZoneIdentifier(_systemTimeZoneIdentifier_). 1. If IsTimeZoneOffsetString(_systemTimeZoneIdentifier_) is *true*_parseResult_.[[OffsetMinutes]] is not ~empty~, then 1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_)_parseResult_.[[OffsetMinutes]] × (60 × 109). 1. Else, 1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, ℤ(ℝ(_t_) × 106)). 1. Let _offsetMs_ be truncate(_offsetNs_ / 106). 1. Return _t_ + 𝔽(_offsetMs_).

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.

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 https://www.iana.org/time-zones/.

Two different input time values _t_UTC are converted to the same local time tlocal 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.).

LocalTime(UTC(_t_local)) is not necessarily always equal to _t_local. Correspondingly, UTC(LocalTime(_t_UTC)) is not necessarily always equal to _t_UTC.

UTC ( _t_: a Number, ): a time value

description
It converts _t_ from local time to a UTC time value. The local political rules for standard time and daylight saving time in effect at _t_ should be used to determine the result in the way specified in this section.
1. If _t_ is not finite, return *NaN*. 1. Let _systemTimeZoneIdentifier_ be SystemTimeZoneIdentifier(). 1. Let _parseResult_ be ! ParseTimeZoneIdentifier(_systemTimeZoneIdentifier_). 1. If IsTimeZoneOffsetString(_systemTimeZoneIdentifier_) is *true*_parseResult_.[[OffsetMinutes]] is not ~empty~, then 1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_)_parseResult_.[[OffsetMinutes]] × (60 × 109). 1. Else, 1. Let _isoDateTime_ be TimeValueToISODateTimeRecord(_t_). 1. Let _possibleInstants_ be GetNamedTimeZoneEpochNanoseconds(_systemTimeZoneIdentifier_, ℝ(YearFromTime(_t_)), ℝ(MonthFromTime(_t_)) + 1, ℝ(DateFromTime(_t_)), ℝ(HourFromTime(_t_)), ℝ(MinFromTime(_t_)), ℝ(SecFromTime(_t_)), ℝ(msFromTime(_t_)), 0, 0_isoDateTime_). 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. 1. If _possibleInstants_ is not empty, then 1. Let _disambiguatedInstant_ be _possibleInstants_[0]. 1. Else, 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). 1. [declared="tBefore"] Let _possibleInstantsBefore_ be GetNamedTimeZoneEpochNanoseconds(_systemTimeZoneIdentifier_, ℝ(YearFromTime(_tBefore_)), ℝ(MonthFromTime(_tBefore_)) + 1, ℝ(DateFromTime(_tBefore_)), ℝ(HourFromTime(_tBefore_)), ℝ(MinFromTime(_tBefore_)), ℝ(SecFromTime(_tBefore_)), ℝ(msFromTime(_tBefore_)), 0, 0TimeValueToISODateTimeRecord(_tBefore_)), 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). 1. Let _disambiguatedInstant_ be the last element of _possibleInstantsBefore_. 1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, _disambiguatedInstant_). 1. Let _offsetMs_ be truncate(_offsetNs_ / 106). 1. Return _t_ - 𝔽(_offsetMs_).

Input _t_ is nominally a time value but may be any Number value. The algorithm must not limit _t_ to the time value range, so that inputs corresponding with a boundary of the time value range can be supported regardless of local UTC offset. For example, the maximum time value is 8.64 × 1015, corresponding with *"+275760-09-13T00:00:00Z"*. 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 × 1015 + 3.6 × 106, corresponding with *"+275760-09-13T01:00:00+01:00"*.

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.

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 https://www.iana.org/time-zones/.

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. In UTC(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0)))), the value of _offsetMs_ is -4 × msPerHour.

2:30 AM on 12 March 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05 (equivalent to 3:30 AM UTC-04). In UTC(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0)))), the value of _offsetMs_ is -5 × msPerHour.

UTC(LocalTime(_t_UTC)) is not necessarily always equal to _t_UTC. Correspondingly, LocalTime(UTC(_t_local)) is not necessarily always equal to _t_local.

[...]

TimeString ( _tv_: a Number, but not *NaN*, ): a String

1. Let _hour_ be ToZeroPaddedDecimalString(ℝ(HourFromTime(_tv_)), 2). 1. Let _minute_ be ToZeroPaddedDecimalString(ℝ(MinFromTime(_tv_)), 2). 1. Let _second_ be ToZeroPaddedDecimalString(ℝ(SecFromTime(_tv_)), 2). 1. Let _timeString_ be FormatTimeString(ℝ(HourFromTime(_tv_)), ℝ(MinFromTime(_tv_)), ℝ(SecFromTime(_tv_)), 0, 0). 1. Return the string-concatenation of _hour_, ":", _minute_, ":", _second__timeString_, the code unit 0x0020 (SPACE), and *"GMT"*.

[...]

TimeZoneString ( _tv_: an integral Number, ): a String

1. Let _systemTimeZoneIdentifier_ be SystemTimeZoneIdentifier(). 1. If IsTimeZoneOffsetString(_systemTimeZoneIdentifier_) is *true*, then 1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_). 1. Else, 1. Let _offsetMinutes_ be ! ParseTimeZoneIdentifier(_systemTimeZoneIdentifier_).[[OffsetMinutes]]. 1. If _offsetMinutes_ is ~empty~, then 1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, ℤ(ℝ(_tv_) × 106)). 1. Set _offsetMinutes_ to truncate(_offsetNs_ / (60 × 109)). 1. Let _offset_ be 𝔽(truncate(_offsetNs_ / 106)). 1. If _offset_ is *+0*𝔽 or _offset_ > *+0*𝔽, then 1. Let _offsetSign_ be *"+"*. 1. Let _absOffset_ be _offset_. 1. Else, 1. Let _offsetSign_ be *"-"*. 1. Let _absOffset_ be -_offset_. 1. Let _offsetMin_ be ToZeroPaddedDecimalString(ℝ(MinFromTime(_absOffset_)), 2). 1. Let _offsetHour_ be ToZeroPaddedDecimalString(ℝ(HourFromTime(_absOffset_)), 2). 1. Let _offsetString_ be FormatOffsetTimeZoneIdentifier(_offsetMinutes_, ~unseparated~). 1. Let _tzName_ be an implementation-defined string that is either the empty String or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-defined timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS). 1. Return the string-concatenation of _offsetSign_, _offsetHour_, _offsetMin_, and _tzName_. 1. Return the string-concatenation of _offsetString_ and _tzName_.

IsTimeZoneOffsetString ( _offsetString_: a String, ): a Boolean

IsOffsetTimeZoneIdentifier ( _offsetString_: a String, ): a Boolean

description
The return value indicates whether _offsetString_ conforms to the grammar given by |UTCOffset||UTCOffset[~SubMinutePrecision]|.
1. Let _parseResult_ be ParseText(StringToCodePoints(_offsetString_), |UTCOffset||UTCOffset[~SubMinutePrecision]|). 1. If _parseResult_ is a List of errors, return *false*. 1. Return *true*.

ParseTimeZoneOffsetString ( _offsetString_: a String, ): an integer

ParseDateTimeUTCOffset ( _offsetString_: a String ): either a normal completion containing an integer or a throw completion

description
The return value is the UTC offset, as a number of nanoseconds, that corresponds to the String _offsetString_. If _offsetString_ is invalid, a *RangeError* is thrown.
1. Let _parseResult_ be ParseText(StringToCodePoints(_offsetString_), |UTCOffset||UTCOffset[+SubMinutePrecision]|). 1. Assert: _parseResult_ is not a List of errors. 1. If _parseResult_ is a List of errors, throw a *RangeError* exception. 1. Assert: _parseResult_ contains a |ASCIISign| Parse Node. 1. Let _parsedSign_ be the source text matched by the |ASCIISign| Parse Node contained within _parseResult_. 1. If _parsedSign_ is the single code point U+002D (HYPHEN-MINUS), then 1. Let _sign_ be -1. 1. Else, 1. Let _sign_ be 1. 1. NOTE: Applications of StringToNumber below do not lose precision, since each of the parsed values is guaranteed to be a sufficiently short string of decimal digits. 1. Assert: _parseResult_ contains an |Hour| Parse Node. 1. Let _parsedHours_ be the source text matched by the |Hour| Parse Node contained within _parseResult_. 1. Let _hours_ be ℝ(StringToNumber(CodePointsToString(_parsedHours_))). 1. If _parseResult_ does not contain a |MinuteSecond| Parse Node, then 1. Let _minutes_ be 0. 1. Else, 1. Let _parsedMinutes_ be the source text matched by the first |MinuteSecond| Parse Node contained within _parseResult_. 1. Let _minutes_ be ℝ(StringToNumber(CodePointsToString(_parsedMinutes_))). 1. If _parseResult_ does not contain two |MinuteSecond| Parse Nodes, then 1. Let _seconds_ be 0. 1. Else, 1. Let _parsedSeconds_ be the source text matched by the second |MinuteSecond| Parse Node contained within _parseResult_. 1. Let _seconds_ be ℝ(StringToNumber(CodePointsToString(_parsedSeconds_))). 1. If _parseResult_ does not contain a |TemporalDecimalFraction| Parse Node, then 1. Let _nanoseconds_ be 0. 1. Else, 1. Let _parsedFraction_ be the source text matched by the |TemporalDecimalFraction| Parse Node contained within _parseResult_. 1. Let _fraction_ be the string-concatenation of CodePointsToString(_parsedFraction_) and *"000000000"*. 1. Let _nanosecondsString_ be the substring of _fraction_ from 1 to 10. 1. Let _nanoseconds_ be ℝ(StringToNumber(_nanosecondsString_)). 1. Return _sign_ × (((_hours_ × 60 + _minutes_) × 60 + _seconds_) × 109 + _nanoseconds_).

The Date Constructor

Date ( ..._values_ )

This function performs the following steps when called:

1. If NewTarget is *undefined*, then 1. Let _now_ be the time value (UTC) identifying the current time. 1. Return ToDateString(_now_). 1. If NewTarget is *undefined*, return ToDateString(SystemUTCEpochMilliseconds()). 1. Let _numberOfArgs_ be the number of elements in _values_. 1. If _numberOfArgs_ = 0, then 1. Let _dv_ be the time value (UTC) identifying the current time SystemUTCEpochMilliseconds(). 1. Else if _numberOfArgs_ = 1, then 1. Let _value_ be _values_[0]. 1. If _value_ is an Object and _value_ has a [[DateValue]] internal slot, then 1. Let _tv_ be _value_.[[DateValue]]. 1. Else, 1. Let _v_ be ? ToPrimitive(_value_). 1. If _v_ is a String, then 1. Assert: The next step never returns an abrupt completion because _v_ is a String. 1. Let _tv_ be the result of parsing _v_ as a date, in exactly the same manner as for the `parse` method (). 1. Else, 1. Let _tv_ be ? ToNumber(_v_). 1. Let _dv_ be TimeClip(_tv_). 1. Else, 1. Assert: _numberOfArgs_ ≥ 2. 1. Let _y_ be ? ToNumber(_values_[0]). 1. Let _m_ be ? ToNumber(_values_[1]). 1. If _numberOfArgs_ > 2, let _dt_ be ? ToNumber(_values_[2]); else let _dt_ be *1*𝔽. 1. If _numberOfArgs_ > 3, let _h_ be ? ToNumber(_values_[3]); else let _h_ be *+0*𝔽. 1. If _numberOfArgs_ > 4, let _min_ be ? ToNumber(_values_[4]); else let _min_ be *+0*𝔽. 1. If _numberOfArgs_ > 5, let _s_ be ? ToNumber(_values_[5]); else let _s_ be *+0*𝔽. 1. If _numberOfArgs_ > 6, let _milli_ be ? ToNumber(_values_[6]); else let _milli_ be *+0*𝔽. 1. Let _yr_ be MakeFullYear(_y_). 1. Let _finalDate_ be MakeDate(MakeDay(_yr_, _m_, _dt_), MakeTime(_h_, _min_, _s_, _milli_)). 1. Let _dv_ be TimeClip(UTC(_finalDate_)). 1. Let _O_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Date.prototype%"*, « [[DateValue]] »). 1. Set _O_.[[DateValue]] to _dv_. 1. Return _O_.

Properties of the Date Constructor

Date.now ( )

This function returns the time value designating the UTC date and time of the occurrence of the call to it.

This function performs the following steps when called:

1. Return SystemUTCEpochMilliseconds().

Properties of the Date Prototype Object

Date.prototype.toTemporalInstant ( )

This method performs the following steps when called:

1. Let _dateObject_ be the *this* value. 1. Perform ? RequireInternalSlot(_dateObject_, [[DateValue]]). 1. Let _t_ be _dateObject_.[[DateValue]]. 1. Let _ns_ be ? NumberToBigInt(_t_) × ℤ(106). 1. Return ! CreateTemporalInstant(_ns_).