This document is a preview of the specification for
PR #3966
commit 3d4a6e7124a6878cb5af3132af7e01e01a88317f,
and should only be used as a historical reference. This commit may not
have even been merged into the specification.
Do not attempt to implement this version of the specification. Do not
reference this version as authoritative in any way. Instead, see
https://github.com/tc39/ecma262 for the
living specification.
22.1.1 Overview of Date Objects and Definitions of Abstract Operations
The following abstract operations operate on time values (defined in 22.1.1.1). Note that, in every case, if any argument to one of these functions is NaN, the result will be NaN.
22.1.1.1 Time Values and Time Range
Time measurement in ECMAScript is analogous to time measurement in POSIX, in particular sharing definition in terms of the proleptic Gregorian calendar, an epoch of midnight at the beginning of 1 January 1970 UTC, and an accounting of every day as comprising exactly 86,400 seconds (each of which is 1000 milliseconds long).
An ECMAScript time value is a Number, either a finiteintegral Number representing an instant in time to millisecond precision or NaN representing no specific instant. A time value that is an integer multiple of MillisecondsPerDay (i.e., is MillisecondsPerDay × d for some integerd) represents the instant at the start of the UTC day that follows the epoch by d whole UTC days (preceding the epoch for negative d). Every other finite time value tv is defined relative to the greatest preceding time value s that is such a multiple, and represents the instant that occurs within the same UTC day as s but follows it by (tv - s) milliseconds.
Time values do not account for UTC leap seconds—there are no time values representing instants within positive leap seconds, and there are time values representing instants removed from the UTC timeline by negative leap seconds. However, the definition of time values nonetheless yields piecewise alignment with UTC, with discontinuities only at leap second boundaries and zero difference outside of leap seconds.
A Number can exactly represent all integers from -9,007,199,254,740,992 to 9,007,199,254,740,992 (21.1.2.8 and 21.1.2.6). A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds. This yields a supported time value range of exactly -100,000,000 days to 100,000,000 days relative to midnight at the beginning of 1 January 1970 UTC.
The exact moment of midnight at the beginning of 1 January 1970 UTC is represented by the time value +0𝔽.
Note
In the proleptic Gregorian calendar, leap years are precisely those which are both divisible by 4 and either divisible by 400 or not divisible by 100.
The 400 year cycle of the proleptic Gregorian calendar contains 97 leap years. This yields an average of 365.2425 days per year, which is 31,556,952,000 milliseconds. Therefore, the maximum range a Number could represent exactly with millisecond precision is approximately -285,426 to 285,426 years relative to 1970. The smaller range supported by a time value as specified in this section is approximately -273,790 to 273,790 years relative to 1970.
22.1.1.2 Time-related Constants
These constants are referenced by algorithms in the following sections.
The abstract operation Day takes argument tv (a finitetime value) and returns an integer. It returns the day number of the day in which tv falls. It performs the following steps when called:
The abstract operation TimeWithinDay takes argument tv (a finitetime value) and returns an integer in the interval from 0 (inclusive) to MillisecondsPerDay (exclusive). It returns the number of milliseconds since the start of the day in which tv falls. It performs the following steps when called:
The abstract operation DayFromYear takes argument y (an integer) and returns an integer. It returns the day number of the first day of year y. It performs the following steps when called:
NOTE: In the following steps, numberYears1, numberYears4, numberYears100, and numberYears400 represent the number of years divisible by 1, 4, 100, and 400, respectively, that occur between the epoch and the start of year y. The number is negative if y is before the epoch.
The abstract operation TimeFromYear takes argument y (an integer) and returns a time value. It returns the time value of the start of year y. It performs the following steps when called:
The abstract operation YearFromTime takes argument tv (a finitetime value) and returns an integer. It returns the year in which tv falls. It performs the following steps when called:
The abstract operation DayWithinYear takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 365. It performs the following steps when called:
The abstract operation InLeapYear takes argument tv (a finitetime value) and returns 0 or 1. It returns 1 if tv is within a leap year and 0 otherwise. It performs the following steps when called:
The abstract operation MonthFromTime takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 11. It returns an integer identifying the month in which tv falls. A month value of 0 specifies January; 1 specifies February; 2 specifies March; 3 specifies April; 4 specifies May; 5 specifies June; 6 specifies July; 7 specifies August; 8 specifies September; 9 specifies October; 10 specifies November; and 11 specifies December. Note that MonthFromTime(+0𝔽) = 0, corresponding to Thursday, 1 January 1970. It performs the following steps when called:
The abstract operation DateFromTime takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 1 to 31. It returns the day of the month in which tv falls. It performs the following steps when called:
The abstract operation WeekDay takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 6. It returns an integer identifying the day of the week in which tv falls. A weekday value of 0 specifies Sunday; 1 specifies Monday; 2 specifies Tuesday; 3 specifies Wednesday; 4 specifies Thursday; 5 specifies Friday; and 6 specifies Saturday. Note that WeekDay(+0𝔽) = 4, corresponding to Thursday, 1 January 1970. It performs the following steps when called:
The abstract operation HourFromTime takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 23. It returns the hour of the day in which tv falls. It performs the following steps when called:
The abstract operation MinuteFromTime takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 59. It returns the minute of the hour in which tv falls. It performs the following steps when called:
The abstract operation SecondFromTime takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 59. It returns the second of the minute in which tv falls. It performs the following steps when called:
The abstract operation MillisecondFromTime takes argument tv (a finitetime value) and returns an integer in the inclusive interval from 0 to 999. It returns the millisecond of the second in which tv falls. It performs the following steps when called:
The abstract operation GetUTCEpochNanoseconds takes argument isoDateTime (an ISO Date-Time Record) and returns an epoch nanoseconds count. The returned value is the epoch nanoseconds count that corresponds to the given ISO 8601 calendar date and wall-clock time in UTC. It performs the following steps when called:
Let date be MakeDay(𝔽(isoDateTime.[[ISODate]].[[Year]]), 𝔽(isoDateTime.[[ISODate]].[[Month]] - 1), 𝔽(isoDateTime.[[ISODate]].[[Day]])).
Let time be MakeTime(𝔽(isoDateTime.[[Time]].[[Hour]]), 𝔽(isoDateTime.[[Time]].[[Minute]]), 𝔽(isoDateTime.[[Time]].[[Minute]]), 𝔽(isoDateTime.[[Time]].[[Millisecond]])).
The abstract operation LocalTime takes argument tv (a finitetime value) and returns an integral Number.
It converts tv from UTC to local time.
The local political rules for standard time and daylight saving time in effect at tv should be used to determine the result in the way specified in this section.
It performs the following steps when called:
Two different input time valuestvUTC 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(tvlocal)) is not necessarily always equal to tvlocal. Correspondingly, UTC(LocalTime(tvUTC)) is not necessarily always equal to tvUTC.
22.1.1.19 UTC ( t )
The abstract operation UTC takes argument t (a Number) and returns a time value.
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.
It performs the following steps when called:
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.
If possibleInstants is not empty, then
Let disambiguatedInstant be possibleInstants[0].
Else,
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).
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".
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 offsetMilliseconds is -4 × MillisecondsPerHour.
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 offsetMilliseconds is -5 × MillisecondsPerHour.
Note 2
UTC(LocalTime(tUTC)) is not necessarily always equal to tUTC. Correspondingly, LocalTime(UTC(tlocal)) is not necessarily always equal to tlocal.
The abstract operation MakeTime takes arguments hour (a Number), minute (a Number), second (a Number), and millisecond (a Number) and returns a Number. It calculates a number of milliseconds. It performs the following steps when called:
If hour is not finite, minute is not finite, second is not finite, or millisecond is not finite, return NaN.
The arithmetic in MakeTime is floating-point arithmetic, which is not associative, so the operations must be performed in the correct order.
22.1.1.21 MakeDay ( year, month, day )
The abstract operation MakeDay takes arguments year (a Number), month (a Number), and day (a Number) and returns a finite Number or NaN. It calculates a number of days. It performs the following steps when called:
If year is not finite, month is not finite, or day is not finite, return NaN.
The abstract operation MakeDate takes arguments day (a Number) and time (a Number) and returns a finite Number or NaN. It calculates a number of milliseconds. It performs the following steps when called:
If day is not finite or time is not finite, return NaN.
The abstract operation MakeFullYear takes argument year (a Number) and returns an integral Number or NaN. It returns the full year associated with the integer part of year, interpreting any value in the inclusive interval from 0 to 99 as a count of years since the start of 1900. For alignment with the proleptic Gregorian calendar, “full year” is defined as the signed count of complete years since the start of year 0 (1 B.C.). It performs the following steps when called:
The abstract operation TimeClip takes argument time (a Number) and returns a time value. It calculates a number of milliseconds. It performs the following steps when called:
ECMAScript defines a string interchange format for date-times which is adapted from the ISO 8601 calendar date extended format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ
Where the elements are as follows:
YYYY
is the year in the proleptic Gregorian calendar as four decimal digits from 0000 to 9999, or as an expanded year of "+" or "-" followed by six decimal digits.
-
"-" (hyphen) appears literally twice in the string.
MM
is the month of the year as two decimal digits from 01 (January) to 12 (December).
DD
is the day of the month as two decimal digits from 01 to 31.
T
"T" appears literally in the string, to indicate the beginning of the time element.
HH
is the number of complete hours that have passed since midnight as two decimal digits from 00 to 24.
:
":" (colon) appears literally twice in the string.
mm
is the number of complete minutes since the start of the hour as two decimal digits from 00 to 59.
ss
is the number of complete seconds since the start of the minute as two decimal digits from 00 to 59.
.
"." (dot) appears literally in the string.
sss
is the number of complete milliseconds since the start of the second as three decimal digits.
Z
is the UTC offset representation specified as "Z" (for UTC with no offset) or as either "+" or "-" followed by a time expression HH:mm (a subset of the time zone offset string format for indicating local time ahead of or behind UTC, respectively)
This format includes date-only forms:
YYYY
YYYY-MM
YYYY-MM-DD
It also includes “date-time” forms that consist of one of the above date-only forms immediately followed by one of the following time forms with an optional UTC offset representation appended:
THH:mm
THH:mm:ss
THH:mm:ss.sss
A string containing out-of-bounds or nonconforming elements is not a valid instance of this format.
Note 1
As every day both starts and ends with midnight, the two notations 00:00 and 24:00 are available to distinguish the two midnights that can be associated with one date. This means that the following two notations refer to exactly the same point in time: 1995-02-04T24:00 and 1995-02-05T00:00.
Note 2
This format does not support annotations with a time zone name as defined in RFC 9557, only a numeric representation of the time zone offset. For strings with a time zone annotation, see 22.4.
22.1.1.25.1 Expanded Years
Covering the full time value range of approximately 273,790 years forward or backward from 1 January 1970 (22.1.1.1) requires representing years before 0 or after 9999. ISO 8601 permits expansion of the year representation, but only by mutual agreement of the partners in information interchange. In the simplified ECMAScript format, such an expanded year representation shall have 6 digits and is always prefixed with a + or - sign. The year 0 is considered positive and must be prefixed with a + sign. The representation of the year 0 as -000000 is invalid. Strings matching the Date Time String Format with expanded years representing instants in time outside the range of a time value are treated as unrecognizable by Date.parse and cause that function to return NaN without falling back to implementation-specific behaviour or heuristics.
Note
Examples of date-time values with expanded years:
-271821-04-20T00:00:00Z
271822 B.C.
-000001-01-01T00:00:00Z
2 B.C.
+000000-01-01T00:00:00Z
1 B.C.
+000001-01-01T00:00:00Z
1 A.D.
+001970-01-01T00:00:00Z
1970 A.D.
+002009-12-15T00:00:00Z
2009 A.D.
+275760-09-13T00:00:00Z
275760 A.D.
22.1.1.26 Time Zone Offset String Format
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 grammar in 22.4.1.
The abstract operation ParseDateTimeUTCOffset takes argument offsetString (a String) and returns either a normal completion containing an integer in the interval from -NanosecondsPerDay (exclusive) to NanosecondsPerDay (exclusive), or a throw completion. It returns the UTC offset, as a number of nanoseconds, that corresponds to the String offsetString.
If offsetString is invalid, a RangeError is thrown. It performs the following steps when called:
Let parseResult be ParseText(offsetString, UTCOffset[+SubMinutePrecision]).
If parseResult is not a Parse Node, throw a RangeError exception.
If parsedSign is the single code point U+002D (HYPHEN-MINUS), then
Let sign be -1.
Else,
Let sign be 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.
22.1.1.27 HostSystemUTCEpochNanoseconds ( global )
The host-defined abstract operation HostSystemUTCEpochNanoseconds takes argument global (a global object) and returns an epoch nanoseconds count.
It allows host environments to reduce the precision of the result.
In particular, web browsers artificially limit it to prevent abuse of security flaws
(e.g., Spectre) and to avoid certain methods of fingerprinting.
An implementation of HostSystemUTCEpochNanoseconds must conform to the following requirements:
This operation provides the current time to the Dateconstructor (22.1.2.1), Date.now (22.1.3.1), and the functions on the Temporal.Now object.
The range requirement is necessary if the system clock is set to a time outside the range that Date and Temporal.Instant objects can represent.
This is not expected to affect implementations in practice.
The default implementation of HostSystemUTCEpochNanoseconds performs the following steps when called:
Let epochNanoseconds be the approximate current UTC date and time, in nanoseconds since the epoch.
is the initial value of the "Date" property of the global object.
creates and initializes a new Date when called as a constructor.
returns a String representing the current time (UTC) when called as a function rather than as a constructor.
is a function whose behaviour differs based upon the number and types of its arguments.
may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Date behaviour must include a super call to the Date constructor to create and initialize the subclass instance with a [[DateValue]] internal slot.
22.1.2.1 Date ( ...values )
This function performs the following steps when called:
This function applies the ToString operator to its argument. If ToString results in an abrupt completion the Completion Record is immediately returned. Otherwise, this function interprets the resulting String as a date and time; it returns a Number, the UTC time value corresponding to the date and time. The String may be interpreted as a local time, a UTC time, or a time in some other time zone, depending on the contents of the String. The function first attempts to parse the String according to the format described in Date Time String Format (22.1.1.25), including expanded years. If the String does not conform to that format the function may fall back to any implementation-specific heuristics or implementation-specific date formats. Strings that are unrecognizable or contain out-of-bounds format element values shall cause this function to return NaN.
If the String conforms to the Date Time String Format, substitute values take the place of absent format elements. When the MM or DD elements are absent, "01" is used. When the HH, mm, or ss elements are absent, "00" is used. When the sss element is absent, "000" is used. When the UTC offset representation is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as a local time.
If x is any Date whose milliseconds amount is zero within a particular implementation of ECMAScript, then all of the following expressions should produce the same numeric value in that implementation, if all the properties referenced have their initial values:
is not required to produce the same Number value as the preceding three expressions and, in general, the value produced by this function is implementation-defined when given any String value that does not conform to the Date Time String Format (22.1.1.25) and that could not be produced in that implementation by the toString or toUTCString method.
This function differs from the Date constructor in two ways: it returns a time value as a Number, rather than creating a Date, and it interprets the arguments in UTC rather than as local time.
Unless explicitly defined otherwise, the methods of the Date prototype object defined below are not generic and the this value passed to them must be an object that has a [[DateValue]] internal slot that has been initialized to a time value.
22.1.4.1 Date.prototype.constructor
The initial value of Date.prototype.constructor is %Date%.
22.1.4.2 Date.prototype.getDate ( )
This method performs the following steps when called:
If month is not present, this method behaves as if month was present with the value getMonth(). If day is not present, it behaves as if day was present with the value getDate().
If minute is not present, this method behaves as if minute was present with the value getMinutes(). If second is not present, it behaves as if second was present with the value getSeconds(). If millisecond is not present, it behaves as if millisecond was present with the value getMilliseconds().
If second is not present, this method behaves as if second was present with the value getSeconds(). If millisecond is not present, this behaves as if millisecond was present with the value getMilliseconds().
22.1.4.25 Date.prototype.setMonth ( month [ , day ] )
This method performs the following steps when called:
If month is not present, this method behaves as if month was present with the value getUTCMonth(). If day is not present, it behaves as if day was present with the value getUTCDate().
If minute is not present, this method behaves as if minute was present with the value getUTCMinutes(). If second is not present, it behaves as if second was present with the value getUTCSeconds(). If millisecond is not present, it behaves as if millisecond was present with the value getUTCMilliseconds().
If second is not present, this method behaves as if second was present with the value getUTCSeconds(). If millisecond is not present, it behaves as if millisecond was present with the value return by getUTCMilliseconds().
22.1.4.33 Date.prototype.setUTCMonth ( month [ , day ] )
This method performs the following steps when called:
If tv corresponds with a year that cannot be represented in the Date Time String Format, throw a RangeError exception.
Return a String representation of tv in the Date Time String Format on the UTC time scale, including all format elements and the UTC offset representation "Z".
22.1.4.37 Date.prototype.toJSON ( key )
This method provides a String representation of a Date for use by JSON.stringify (26.5.4).
This method is intentionally generic; it does not require that its this value be a Date. Therefore, it can be transferred to other kinds of objects for use as a method. However, it does require that any such object have a toISOString method.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402. Otherwise, the following specification of this method is used:
This method returns a String value. The contents of the String are implementation-defined, but are intended to represent the “date” portion of the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment's current locale.
The meaning of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402. Otherwise, the following specification of this method is used:
This method returns a String value. The contents of the String are implementation-defined, but are intended to represent the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment's current locale.
The meaning of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402. Otherwise, the following specification of this method is used:
This method returns a String value. The contents of the String are implementation-defined, but are intended to represent the “time” portion of the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment's current locale.
The meaning of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
22.1.4.41 Date.prototype.toString ( )
This method performs the following steps when called:
For any Date d such that d.[[DateValue]] is evenly divisible by 1000, the result of Date.parse(d.toString()) = d.valueOf(). See 22.1.3.2.
Note 2
This method is not generic; it throws a TypeError exception if its this value is not a Date. Therefore, it cannot be transferred to other kinds of objects for use as a method.
22.1.4.41.1 TimeString ( tv )
The abstract operation TimeString takes argument tv (a Number, but not NaN) and returns a String. It performs the following steps when called:
Return the string-concatenation of weekday, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), yearSign, and paddedYear.
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).
This method returns a String value representing the instant in time corresponding to the this value. The format of the String is based upon HTTP-date from RFC 7231, generalized to support the full range of times supported by ECMAScript Dates.
Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv).
22.1.4.45 Date.prototype.valueOf ( )
This method performs the following steps when called:
22.1.4.46 Date.prototype [ %Symbol.toPrimitive% ] ( hint )
This method is called by ECMAScript language operators to convert a Date to a primitive value. The allowed values for hint are "default", "number", and "string". Dates are unique among built-in ECMAScript object in that they treat "default" as being equivalent to "string", All other built-in ECMAScript objects treat "default" as being equivalent to "number".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
The value of the "name" property of this method is "[Symbol.toPrimitive]".
22.1.5 Properties of Date Instances
Date instances are ordinary objects that inherit properties from the Date prototype object. Date instances also have a [[DateValue]] internal slot. The [[DateValue]] internal slot is the time value represented by this Date.
22.2 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 0x0021 to 0x007E, described by TimeZoneIdentifier in the grammar below.
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 a String s for which ParseText(s, UTCOffset[~SubMinutePrecision]) returns a Parse Node.
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 of 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 in the grammar below, 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 ECMA-402.
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.
Time zone identifiers are described by the grammar in 22.4.1.
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:30 AM on 5 November 2017 in America/New_York is repeated twice, so GetNamedTimeZoneEpochNanoseconds 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 for that time zone and ISO date-time would return an empty List.
The returned integer represents the offset from UTC in nanoseconds of the named time zone identified by timeZoneIdentifier, at the epoch nanoseconds countepochNanoseconds. Time zone offset values may be positive or negative.
The default implementation of GetNamedTimeZoneOffsetNanoseconds, to be used for ECMAScript implementations that do not include local political rules for any time zones, performs the following steps when called:
The returned value transition is the epoch nanoseconds count that corresponds to the first time zone UTC offset transition strictly after epochNanoseconds in the IANA time zone identified by timeZoneIdentifier.
The operation returns null if no such transition exists for which transition ≤ MaxEpochNanoseconds.
A transition is a point in time where the UTC offset of a time zone changes, for example when daylight saving time starts or stops.
The returned value transition represents the first epoch nanoseconds count where the new UTC offset is used in this time zone, not the last epoch nanoseconds count where the previous UTC offset is used.
In other words, GetOffsetNanosecondsFor(timeZone, transition) ≠ GetOffsetNanosecondsFor(timeZone, transition - 1).
If this operation is called multiple times with the same values for timeZoneIdentifier and epochNanoseconds, the result must be the same for each such call for the lifetime of the surrounding agent.
The default implementation of GetNamedTimeZoneNextTransition for ECMAScript implementations that do not include local political rules for any time zones performs the following steps when called:
The returned value transition is the epoch nanoseconds count that corresponds to the last time zone UTC offset transition strictly before epochNanoseconds in the IANA time zone identified by timeZoneIdentifier.
The operation returns null if no such transition exists for which transition ≥ MinEpochNanoseconds.
A transition is a point in time where the UTC offset of a time zone changes, for example when daylight saving time starts or stops.
The returned value transition represents the first epoch nanoseconds count where the new UTC offset is used in this time zone, not the last epoch nanoseconds count where the previous UTC offset is used.
In other words, GetOffsetNanosecondsFor(timeZone, transition) ≠ GetOffsetNanosecondsFor(timeZone, transition - 1).
If this operation is called multiple times with the same values for timeZoneIdentifier and epochNanoseconds, the result must be the same for each such call for the lifetime of the surrounding agent.
The default implementation of GetNamedTimeZonePreviousTransition for ECMAScript implementations that do not include local political rules for any time zones performs the following steps when called:
Time zone aware implementations, including all implementations that implement the ECMA-402 Internationalization API, must implement the AvailableNamedTimeZoneIdentifiers abstract operation as specified in ECMA-402.
Otherwise, AvailableNamedTimeZoneIdentifiers performs the following steps when called:
If the implementation does not include local political rules for any time zones, then
Let record be the Time Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }.
Append record to result.
Assert: result contains a Time Zone Identifier Recordrecord such that record.[[Identifier]] is "UTC" and record.[[PrimaryIdentifier]] is "UTC".
Return result.
Note
Due to the complexity of supporting the requirements of GetAvailableNamedTimeZoneIdentifier, it is recommended that the result of every call to AvailableNamedTimeZoneIdentifiers be the same for the lifetime of the surrounding agent.
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".
22.2.8 Available Named Time Zone Identifier Return Record
If temporalTimeZoneLikeis an Object and temporalTimeZoneLike has an [[InitializedTemporalZonedDateTime]] internal slot, return temporalTimeZoneLike.[[TimeZone]].
If temporalTimeZoneLikeis not a String, throw a TypeError exception.
The abstract operation TimeZoneEquals takes arguments xTimeZone (an available time zone identifier) and yTimeZone (an available time zone identifier) and returns a Boolean. It returns true if its arguments represent time zones using the same identifier. It performs the following steps when called:
If xRecord.[[PrimaryIdentifier]] is yRecord.[[PrimaryIdentifier]], return true.
Assert: If xTimeZone and yTimeZone are both offset time zone identifiers, they do not represent the same number of offset minutes.
Return false.
22.3 Definitions and Abstract Operations for Temporal Objects
22.3.1 Calendar Date Records and Calendar Fields Records
22.3.1.1 Calendar Date Records
A Calendar Date Record is a Record used to represent a date that exists in a calendar, which may or may not be the ISO 8601 calendar.
Calendar Date Records are produced by the abstract operation CalendarISOToDate.
Calendar Date Records have the fields listed in Table 64.
The ordinal position of the date's year within its era, or empty for calendars that do not have eras.
Note 1
Era years are 1-indexed for many calendars, but not all (e.g., the eras of the Burmese calendar each start with a year 0). Years can also advance opposite the flow of time (as for BCE years in the Gregorian calendar).
The date's year relative to the first day of a calendar-specific “epoch year”.
Note 2
The year is relative to the first day of the calendar's epoch year, so if the epoch era starts in the middle of the year, the year will be the same value before and after the start date of the era.
The 1-based ordinal position of the date's month within its year.
Note 3
When the number of months in a year of the calendar is variable, this field can contain different values for dates that are part of the same month in different years. For example, in the Hebrew calendar, 1 Nisan 5781 is associated with value 7 while 1 Nisan 5782 is associated with value 8 because 5782 is a leap year and Nisan follows the insertion of Adar I.
true if the date falls within a leap year, and false otherwise.
Note 4
A leap year is a year that contains more days than other years (for solar or lunar calendars) or more months than other years (for lunisolar calendars like Hebrew or Chinese).
Some calendars, especially lunisolar ones, have further variation in year length that is not represented in the output of this operation (e.g., the Hebrew calendar includes common years with 353, 354, or 355 days and leap years with 383, 384, or 385 days).
Many of the fields in a Calendar Fields Record have the same meaning as the fields of the same name in Calendar Date Records, but each field in a Calendar Fields Record may additionally be empty to indicate partial input.
Each field has a corresponding calendar property key, which is one of "era", "eraYear", "year", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "offset", or "timeZone".
These property keys correspond to the properties that are read from user input objects to populate the field, in methods such as Temporal.PlainDate.prototype.with (22.11.3.23).
Calendar Fields Records have the fields listed in Table 65.
22.3.1.3 PrepareCalendarFields ( calendar, fields, calendarFields, nonCalendarFields, requiredFields )
The abstract operation PrepareCalendarFields takes arguments calendar (a known calendar type), fields (an Object), calendarFields (date-fields, year-month-fields, only-day, or only-year), nonCalendarFields (time-fields, time-fields-with-offset, time-fields-with-time-zone-and-offset, or no-non-calendar-fields), and requiredFields (partial, time-zone, or no-required-fields) and returns either a normal completion containing a Calendar Fields Record, or a throw completion.
It returns the result of reading from fields all of the property names corresponding to calendarFields and nonCalendarFields, plus any extra fields required by the calendar.
The returned Record has a non-empty value for each property corresponding to calendarFields and nonCalendarFields that has a non-undefined value on fields, which is used as the input for relevant conversion.
When requiredFields is partial, this operation throws if none of the properties are present with a non-undefined value.
When requiredFields is time-zone, this operation throws if fields's "timeZone" property is absent or undefined.
It performs the following steps when called:
If calendarFields is date-fields, then
Let propertyNames be « "day", "month", "monthCode", "year" ».
Else if calendarFields is year-month-fields, then
Let propertyNames be « "month", "monthCode", "year" ».
Let merged be the Calendar Fields Record {
[[Era]]: empty,
[[EraYear]]: empty,
[[Year]]: empty,
[[Month]]: empty,
[[MonthCode]]: empty,
[[Day]]: empty,
[[Hour]]: empty,
[[Minute]]: empty,
[[Second]]: empty,
[[Millisecond]]: empty,
[[Microsecond]]: empty,
[[Nanosecond]]: empty,
[[OffsetString]]: empty,
[[TimeZone]]: empty
}.
If fields.[[Era]] is not empty and overriddenKeys does not contain "era", set merged.[[Era]] to fields.[[Era]].
If additionalFields.[[Era]] is not empty, set merged.[[Era]] to additionalFields.[[Era]].
If fields.[[EraYear]] is not empty and overriddenKeys does not contain "eraYear", set merged.[[EraYear]] to fields.[[EraYear]].
If additionalFields.[[EraYear]] is not empty, set merged.[[EraYear]] to additionalFields.[[EraYear]].
If fields.[[Year]] is not empty and overriddenKeys does not contain "year", set merged.[[Year]] to fields.[[Year]].
If additionalFields.[[Year]] is not empty, set merged.[[Year]] to additionalFields.[[Year]].
If fields.[[Month]] is not empty and overriddenKeys does not contain "month", set merged.[[Month]] to fields.[[Month]].
If additionalFields.[[Month]] is not empty, set merged.[[Month]] to additionalFields.[[Month]].
If fields.[[MonthCode]] is not empty and overriddenKeys does not contain "monthCode", set merged.[[MonthCode]] to fields.[[MonthCode]].
If additionalFields.[[MonthCode]] is not empty, set merged.[[MonthCode]] to additionalFields.[[MonthCode]].
If fields.[[Day]] is not empty and overriddenKeys does not contain "day", set merged.[[Day]] to fields.[[Day]].
If additionalFields.[[Day]] is not empty, set merged.[[Day]] to additionalFields.[[Day]].
If fields.[[Hour]] is not empty and overriddenKeys does not contain "hour", set merged.[[Hour]] to fields.[[Hour]].
If additionalFields.[[Hour]] is not empty, set merged.[[Hour]] to additionalFields.[[Hour]].
If fields.[[Minute]] is not empty and overriddenKeys does not contain "minute", set merged.[[Minute]] to fields.[[Minute]].
If additionalFields.[[Minute]] is not empty, set merged.[[Minute]] to additionalFields.[[Minute]].
If fields.[[Second]] is not empty and overriddenKeys does not contain "second", set merged.[[Second]] to fields.[[Second]].
If additionalFields.[[Second]] is not empty, set merged.[[Second]] to additionalFields.[[Second]].
If fields.[[Millisecond]] is not empty and overriddenKeys does not contain "millisecond", set merged.[[Millisecond]] to fields.[[Millisecond]].
If additionalFields.[[Millisecond]] is not empty, set merged.[[Millisecond]] to additionalFields.[[Millisecond]].
If fields.[[Microsecond]] is not empty and overriddenKeys does not contain "microsecond", set merged.[[Microsecond]] to fields.[[Microsecond]].
If additionalFields.[[Microsecond]] is not empty, set merged.[[Microsecond]] to additionalFields.[[Microsecond]].
If fields.[[Nanosecond]] is not empty and overriddenKeys does not contain "nanosecond", set merged.[[Nanosecond]] to fields.[[Nanosecond]].
If additionalFields.[[Nanosecond]] is not empty, set merged.[[Nanosecond]] to additionalFields.[[Nanosecond]].
If fields.[[OffsetString]] is not empty and overriddenKeys does not contain "offset", set merged.[[OffsetString]] to fields.[[OffsetString]].
If additionalFields.[[OffsetString]] is not empty, set merged.[[OffsetString]] to additionalFields.[[OffsetString]].
If fields.[[TimeZone]] is not empty and overriddenKeys does not contain "timeZone", set merged.[[TimeZone]] to fields.[[TimeZone]].
If additionalFields.[[TimeZone]] is not empty, set merged.[[TimeZone]] to additionalFields.[[TimeZone]].
Return merged.
22.3.2 Calendar Identifiers
At a minimum, ECMAScript implementations must support a calendar named "iso8601", representing the ISO 8601 calendar.
In addition, implementations may support any number of other calendars corresponding with those of the Unicode Common Locale Data Repository (CLDR).
A known calendar type is a calendar type in canonical form that is supported by the implementation.
22.3.2.1 AvailableCalendars ( )
The implementation-defined abstract operation AvailableCalendars takes no arguments and returns a List of calendar types. The returned List is sorted according to lexicographic code unit order, and contains unique calendar types in canonical form (22.3.2) identifying the calendars for which the implementation provides the functionality of Temporal objects, including any aliases.
The default implementation of AvailableCalendars, to be used for ECMAScript implementations that do not support any calendar types other than "iso8601", performs the following steps when called:
The default implementation of CanonicalizeCalendar, to be used for ECMAScript implementations that do not support any calendar types other than "iso8601", performs the following steps when called:
If the ASCII-lowercase of id is not "iso8601", throw a RangeError exception.
The abstract operation GetTemporalCalendarIdentifierWithISODefault takes argument temporalObjectLike (an Object) and returns either a normal completion containing a known calendar type or a throw completion.
It looks for a calendar property on temporalObjectLike and converts its value into a known calendar type.
If no such property is present, the built-in ISO 8601 calendar is returned.
It performs the following steps when called:
If temporalObjectLike has a [[Calendar]] internal slot, return temporalObjectLike.[[Calendar]].
Let calendarLike be ? Get(temporalObjectLike, "calendar").
22.3.3.1 CalendarDateAdd ( calendar, isoDate, duration, overflow )
The abstract operation CalendarDateAdd takes arguments calendar (a known calendar type), isoDate (an ISO Date Record), duration (a Date Duration Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
It adds dateDuration to isoDate using the years, months, and weeks reckoning of calendar.
If addition of years or months results in a nonexistent date, either the nonexistent date will be coerced to an existing date or the operation will throw, depending on the value of overflow.
It performs the following steps when called:
If calendar is "iso8601", then
Let intermediate be BalanceISOYearMonth(isoDate.[[Year]] + duration.[[Years]], isoDate.[[Month]] + duration.[[Months]]).
Set intermediate to ? RegulateISODate(intermediate.[[Year]], intermediate.[[Month]], isoDate.[[Day]], overflow).
Let days be duration.[[Days]] + 7 × duration.[[Weeks]].
22.3.3.2 NonISODateAdd ( calendar, isoDate, duration, overflow )
The implementation-defined abstract operation NonISODateAdd takes arguments calendar (a known calendar type but not "iso8601"), isoDate (an ISO Date Record), duration (a Date Duration Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
The operation performs implementation-defined processing to add duration to date in the context of the calendar identified by calendar and returns the corresponding day, month, and year of the result in the ISO 8601 calendar as an ISO Date Record.
It may throw a RangeError exception if overflow is "reject" and the resulting month or day would not form a date that exists in the calendar identified by calendar.
22.3.3.3 CalendarDateUntil ( calendar, isoDateFrom, isoDateTo, largestUnit )
The abstract operation CalendarDateUntil takes arguments calendar (a known calendar type), isoDateFrom (an ISO Date Record), isoDateTo (an ISO Date Record), and largestUnit (a date unit) and returns a Date Duration Record.
It determines the difference between the dates isoDateFrom and isoDateTo using the years, months, and weeks reckoning of calendar.
No fields larger than largestUnit will be non-zero in the resulting Date Duration Record.
It performs the following steps when called:
In the resulting Date Duration Recordr, r.[[Years]] = 0 if largestUnit is one of "months", "weeks", or "days".
Likewise, r.[[Months]] = 0 if largestUnit is either "weeks" or "days", and r.[[Weeks]] = 0 if largestUnit is "days".
22.3.3.5 CalendarDateToISO ( calendar, fields, overflow )
The abstract operation CalendarDateToISO takes arguments calendar (a known calendar type), fields (a Calendar Fields Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
It returns an ISO Date Record representing a date in the ISO 8601 calendar that, when converted to calendar, corresponds to the date of fields.
The fields argument represents a date in the calendar identified by calendar, though it may include additional fields.
If an ISO Date Record cannot be created from fields because its date does not exist, the values from fields are clamped to their respective valid ranges if overflow is "constrain", as in RegulateISODate; if it is "reject", an exception is thrown.
It performs the following steps when called:
If calendar is "iso8601", then
Assert: fields.[[Year]], fields.[[Month]], and fields.[[Day]] are not empty.
22.3.3.6 NonISOCalendarDateToISO ( calendar, fields, overflow )
The implementation-defined abstract operation NonISOCalendarDateToISO takes arguments calendar (a known calendar type but not "iso8601"), fields (a Calendar Fields Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
It performs implementation-defined processing to return an ISO Date Record representing a date in the ISO 8601 calendar that, when converted to calendar, corresponds to the date of fields.
The fields argument represents a date in the calendar identified by calendar, though it may include additional fields.
If an ISO Date Record cannot be created from fields because its date does not exist, the values from fields are clamped to their respective valid ranges if overflow is "constrain"; if it is "reject", an exception is thrown.
Clamping a nonexistent date to the correct range when overflow is "constrain" is a behaviour specific to each calendar, but all calendars follow this guideline:
Pick the closest day in the same month. If there are two equally-close dates in that month, pick the later one.
If the month is a leap month that doesn't exist in the year, pick another date according to the cultural conventions of that calendar's users. Usually this will result in the same day in the month before or after where that month would normally fall in a leap year.
Otherwise, pick the closest date that is still in the same year. If there are two equally-close dates in that year, pick the later one.
If the entire year doesn't exist, pick the closest date in a different year. If there are two equally-close dates, pick the later one.
22.3.3.7 CalendarMonthDayToISOReferenceDate ( calendar, fields, overflow )
The abstract operation CalendarMonthDayToISOReferenceDate takes arguments calendar (a known calendar type), fields (a Calendar Fields Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
It returns an ISO Date Record representing a reference date in the ISO 8601 calendar that, when converted to calendar, corresponds to the month and day of fields.
The fields argument represents a month and day in the calendar identified by calendar, though it may include additional fields.
The month and day are checked using the year in fields, if present; the year is used only for this check and is otherwise ignored in favour of a reference year.
For the ISO 8601 calendar, the reference year is always 1972. For other calendars, see NonISOMonthDayToISOReferenceDate.
If an ISO Date Record cannot be created from fields because its date does not exist, the values from fields are clamped to their respective valid ranges if overflow is "constrain"; if it is "reject", an exception is thrown.
It performs the following steps when called:
If calendar is "iso8601", then
Assert: fields.[[Month]] and fields.[[Day]] are not empty.
Let referenceISOYear be 1972 (the first ISO 8601 leap year after the epoch).
If fields.[[Year]] is empty, let year be referenceISOYear; else let year be fields.[[Year]].
Let result be ? RegulateISODate(year, fields.[[Month]], fields.[[Day]], overflow).
22.3.3.8 NonISOMonthDayToISOReferenceDate ( calendar, fields, overflow )
The implementation-defined abstract operation NonISOMonthDayToISOReferenceDate takes arguments calendar (a known calendar type but not "iso8601"), fields (a Calendar Fields Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
It performs implementation-defined processing to return an ISO Date Record representing a reference date in the ISO 8601 calendar that, when converted to calendar, corresponds to the month and day of fields.
The fields argument represents a month and day in the calendar identified by calendar, though it may include additional fields.
The month and day are checked using the year in fields, if present; the year is used only for this check and is otherwise ignored in favour of a reference year.
If an ISO Date Record cannot be created from fields because its date does not exist, the values from fields are clamped to their respective valid ranges if overflow is "constrain"; if it is "reject", an exception is thrown.
As in NonISOCalendarDateToISO, such clamping is calendar-specific.
The reference date is the latest ISO 8601 date corresponding to the calendar date that is between January 1, 1900 and December 31, 1972 inclusive. If there is no such date, it is the earliest ISO 8601 date corresponding to the calendar date between January 1, 1973 and December 31, 2035 inclusive.
The reference year is almost always 1972 (the first ISO 8601 leap year after the epoch), with exceptions for calendars where some dates (e.g. leap days or days in leap months) didn't occur during that ISO 8601 year. For example, Hebrew calendar leap month Adar I occurred in calendar years 5730 and 5733 (respectively overlapping ISO 8601 February/March 1970 and February/March 1973), but did not occur between them, so the reference year for days of that month is 1970.
The operation throws a RangeError if fields.[[Year]] is not empty and the ISO 8601 year year corresponding to fields.[[Year]] would cause ISODateWithinLimits to return false (i.e., year is not in the inclusive interval from -271,821 to 275,760.)
This is so as not to require calculating whether the month and day described in fields exist in years arbitrarily far in the future or past.
Note this restriction does not apply to CalendarMonthDayToISOReferenceDate when calendar is "iso8601".
Note 1
Example 1: When calendar is "gregory" and overflow is "reject", fields values of { [[MonthCode]]: "M01", [[Day]]: 32 } and { [[Year]]: 2001, [[Month]]: 2, [[Day]]: 29 } would both cause a RangeError to be thrown.
In the latter case, even though February 29 is a date in leap years of the Gregorian calendar, 2001 was not a leap year and a month code cannot be determined from the nonexistent date 2001-02-29 with the specified month index.
Note 2
Example 2: When calendar is "gregory" and overflow is "constrain", a fields value of { [[MonthCode]]: "M02", [[Day]]: 30 } is clamped to { [[Year]]: 1972, [[Month]]: 2, [[Day]]: 29 } (because 29 is the maximum valid day for February) while fields values of { [[Year]]: 2001, [[MonthCode]]: "M02", [[Day]]: 30 } and { [[Era]]: "ce", [[EraYear]]: 2001, [[Month]]: 2, [[Day]]: 30 } (or an equivalent with a supported value for [[Era]] representing the Common Era beginning in ISO 8601 year 1) are clamped to { [[Year]]: 1972, [[Month]]: 2, [[Day]]: 28 } (because 28 is the maximum valid day for February 2001, which did not include a leap day).
22.3.3.9 CalendarISOToDate ( calendar, isoDate )
The abstract operation CalendarISOToDate takes arguments calendar (a known calendar type) and isoDate (an ISO Date Record) and returns a Calendar Date Record. It finds the date corresponding to isoDate in the context of the calendar identified by calendar and returns a Calendar Date Record representing that calendar date, with its fields filled in according to their descriptions. It performs the following steps when called:
22.3.3.11 CalendarExtraFields ( calendar, fields )
The implementation-defined abstract operation CalendarExtraFields takes arguments calendar (a known calendar type) and fields (a List of calendar property keys) and returns a List of calendar property keys. It characterizes calendar-specific fields that are relevant for the provided fields in the calendar identified by calendar. It performs the following steps when called:
If calendar is "iso8601", return a new empty List.
Return an implementation-definedList of calendar property keys that are relevant for the provided fields in the calendar identified by calendar. For example, if calendar reckons time in eras and fields contains "year", return « "era", "eraYear" ».
22.3.3.12 CalendarFieldKeysToIgnore ( calendar, fields )
The abstract operation CalendarFieldKeysToIgnore takes arguments calendar (a known calendar type) and fields (a Calendar Fields Record) and returns a List of calendar property keys.
It determines which fields could potentially conflict with any of the non-empty fields named in fields, for the calendar identified by calendar.
A field always potentially conflicts with at least itself.
It performs the following steps when called:
If calendar is "iso8601", then
Let ignoredFields be a new empty Set.
If fields.[[Era]] is not empty, add "era" to ignoredFields.
If fields.[[EraYear]] is not empty, add "eraYear" to ignoredFields.
If fields.[[Year]] is not empty, add "year" to ignoredFields.
If fields.[[Month]] is not empty or fields.[[MonthCode]] is not empty, add "month" and "monthCode" to ignoredFields.
If fields.[[Day]] is not empty, add "day" to ignoredFields.
If fields.[[Hour]] is not empty, add "hour" to ignoredFields.
If fields.[[Minute]] is not empty, add "minute" to ignoredFields.
If fields.[[Second]] is not empty, add "second" to ignoredFields.
If fields.[[Millisecond]] is not empty, add "millisecond" to ignoredFields.
If fields.[[Microsecond]] is not empty, add "microsecond" to ignoredFields.
If fields.[[Nanosecond]] is not empty, add "nanosecond" to ignoredFields.
22.3.3.13 NonISOFieldKeysToIgnore ( calendar, fields )
The implementation-defined abstract operation NonISOFieldKeysToIgnore takes arguments calendar (a known calendar type but not "iso8601") and fields (a Calendar Fields Record) and returns a List of calendar property keys.
It performs implementation-defined processing to determine which fields could potentially conflict with any of the non-empty fields of fields, for the calendar identified by calendar.
A field always potentially conflicts with at least itself.
This operation is relevant for calendars which accept fields other than the standard set of ISO 8601 calendar fields, in order to implement the Temporal objects' with() methods in such a way that the result is free of ambiguity or conflicts.
For example, given a calendar that uses eras, such as "gregory", any one of fields.[[Year]], fields.[[Era]], or fields.[[EraYear]] being non-empty would exclude all three.
Passing any one of the three to a with() method might conflict with either of the other two properties on the receiver object, so those properties of the receiver object should be ignored.
Given this, in addition to the ISO 8601 mutual exclusion of "month" and "monthCode", a possible implementation might produce the following results when calendar is "gregory":
In a calendar such as "japanese" where eras do not start and end at year and/or month boundaries, note that the returned List should contain "era" and "eraYear" if fields.[[Day]], fields.[[Month]], or fields.[[MonthCode]] are non-empty (not only fields.[[Year]], fields.[[Era]], or fields.[[EraYear]], as in the example above) because it's possible that changing the day or month would cause a conflict with the era.
22.3.3.14 CalendarResolveFields ( calendar, fields, type )
The abstract operation CalendarResolveFields takes arguments calendar (a known calendar type), fields (a Calendar Fields Record), and type (date, year-month, or month-day) and returns either a normal completion containingunused or a throw completion.
It validates that fields (which describes a date or partial date in the calendar identified by calendar) is sufficiently complete to satisfy type and not internally inconsistent, and mutates fields into acceptable input for CalendarDateToISO ( calendar, fields, overflow ) or CalendarMonthDayToISOReferenceDate ( calendar, fields, overflow ) by merging data that can be represented in multiple forms into standard fields and removing redundant fields (for example, merging [[Era]] and [[EraYear]] into [[Year]]).
It performs the following steps when called:
If calendar is "iso8601", then
Let needsYear be false.
If type is either date or year-month, set needsYear to true.
Let needsDay be false.
If type is either date or month-day, set needsDay to true.
If needsYear is true and fields.[[Year]] is empty, throw a TypeError exception.
If needsDay is true and fields.[[Day]] is empty, throw a TypeError exception.
If fields.[[Month]] is empty and fields.[[MonthCode]] is empty, throw a TypeError exception.
If fields.[[MonthCode]] is not empty, then
Let parsedMonthCode be ! ParseMonthCode(fields.[[MonthCode]]).
If parsedMonthCode.[[IsLeapMonth]] is true, throw a RangeError exception.
Let month be parsedMonthCode.[[MonthNumber]].
If month > 12, throw a RangeError exception.
If fields.[[Month]] is not empty and fields.[[Month]] ≠ month, throw a RangeError exception.
The operation throws a TypeError exception if the non-empty fields of fields are insufficient to identify a unique instance of type in the calendar (e.g., when at least one field in each combination capable of determining some part of its data is empty) or a RangeError exception if the fields are sufficient but their values are internally inconsistent within the calendar (e.g., when fields such as [[Month]] and [[MonthCode]] have conflicting non-empty values). For example:
If type is either date or month-day, “day” in the calendar has an interpretation similar to ISO 8601, and fields.[[Day]] is empty.
If fields.[[MonthCode]] identifies a month code that is not valid in any year of the calendar.
If fields.[[Month]] and fields.[[MonthCode]] are both empty or neither value is empty but they do not identify the same month.
If type is month-day, fields.[[MonthCode]] is empty, and a specific year cannot be determined from fields.
If the calendar supports the usual partitioning of years into eras with their own year counting as represented by “year”, “era”, and “era year” (as in the Gregorian or traditional Japanese calendars) and any of the following cases apply:
type is date or year-month and each of fields.[[Year]], fields.[[Era]], and fields.[[EraYear]] is empty.
fields.[[Era]] is empty but fields.[[EraYear]] is not.
fields.[[EraYear]] is empty but fields.[[Era]] is not.
None of the three values are empty but fields.[[Era]] and fields.[[EraYear]] do not together identify the same year as fields.[[Year]].
In some cases, verifying the internal consistency of two fields requires the data from other fields, such as checking fields.[[MonthCode]]"M06" against fields.[[Month]] 7 in the Hebrew calendar (which are consistent if and only if fields identifies a year that includes leap month Adar I).
Note 1
When the fields of fields are inconsistent with respect to a non-emptyfields.[[Era]], it is recommended that fields.[[Era]] and fields.[[EraYear]] be updated to resolve the inconsistency by lenient interpretation of out-of-bounds values (rather than throwing a RangeError), which is particularly useful for consistent interpretation of dates in calendars with regnal eras.
In the Gregorian calendar, a zero or negative fields.[[EraYear]] should be replaced with a positive [[EraYear]] corresponding with extension of the era into its complement and fields.[[Era]] should be updating accordingly (such that Common Era [[EraYear]] 0 is updated to Before Common Era [[EraYear]] 1, Before Common Era [[EraYear]] -1 is updated to Common Era [[EraYear]] 2, etc.).
In the Japanese calendar, when fields.[[Era]] is not empty and the date represented by fields is not within the bounds of that era, fields.[[Era]] should be updated to the appropriate containing era for that date (for example, because the transition from Heisei era [[EraYear]] 31 to Reiwa era [[EraYear]] 1 took place on May 1 of [[Year]] 2019, Heisei era [[EraYear]] 32 should be updated to Reiwa era [[EraYear]] 2, Reiwa era [[EraYear]] 1 [[Month]] 1 should be updated to Heisei era [[EraYear]] 31 [[Month]] 1, etc.).
Note 2
When type is month-day and fields.[[Month]] is not empty, it is recommended that all calendars other than the ISO 8601 calendar require a disambiguating year (e.g., either fields.[[Year]] or fields.[[Era]] and fields.[[EraYear]]) to avoid a TypeError, regardless of whether or not fields.[[MonthCode]] is empty. The ISO 8601 calendar allows fields.[[Year]] to be empty in this case because it is a special default calendar that is permanently stable for automated processing.
22.3.3.16 CalendarDateFromFields ( calendar, fields, overflow )
22.3.3.17 CalendarYearMonthFromFields ( calendar, fields, overflow )
The abstract operation CalendarYearMonthFromFields takes arguments calendar (a known calendar type), fields (a Calendar Fields Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion. It converts a calendar month in the reckoning of calendar, if it is uniquely determined by fields, into an ISO Date Record representing the first day of that month. It performs the following steps when called:
22.3.3.18 CalendarMonthDayFromFields ( calendar, fields, overflow )
The abstract operation CalendarMonthDayFromFields takes arguments calendar (a known calendar type), fields (a Calendar Fields Record), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion. It converts a calendar month-day in the reckoning of calendar, if it is uniquely determined by fields, into an ISO Date Record representing that day in an appropriate reference year. It performs the following steps when called:
A Date Duration Record is a Record used to represent the portion of a duration calculation that deals with calendar date units.
Date Duration Records are produced by the abstract operation CreateDateDurationRecord, among others.
Note
See the note in 22.15.4 regarding implementation storage requirements for these fields.
Date Duration Records have the fields listed in Table 67.
If DateDurationSign(yearsMonthsWeeksDuration) = 0, return dateDuration.[[Days]].
Let isoDateTo be ? CalendarDateAdd(plainRelativeTo.[[Calendar]], plainRelativeTo.[[ISODate]], yearsMonthsWeeksDuration, "constrain").
Let epochDaysFrom be ISODateToEpochDays(plainRelativeTo.[[ISODate]].[[Year]], plainRelativeTo.[[ISODate]].[[Month]], plainRelativeTo.[[ISODate]].[[Day]]).
Let epochDaysTo be ISODateToEpochDays(isoDateTo.[[Year]], isoDateTo.[[Month]], isoDateTo.[[Day]]).
Let yearsMonthsWeeksInDays be epochDaysTo - epochDaysFrom.
The abstract operation DateDurationSign takes argument dateDuration (a Date Duration Record) and returns -1, 0, or 1. It returns 1 if the most significant non-zero field in the dateDuration argument is positive, and -1 if the most significant non-zero field is negative. If all of dateDuration's fields are zero, it returns 0. It performs the following steps when called:
If dateDuration.[[Years]] < 0, return -1.
If dateDuration.[[Years]] > 0, return 1.
If dateDuration.[[Months]] < 0, return -1.
If dateDuration.[[Months]] > 0, return 1.
If dateDuration.[[Weeks]] < 0, return -1.
If dateDuration.[[Weeks]] > 0, return 1.
If dateDuration.[[Days]] < 0, return -1.
If dateDuration.[[Days]] > 0, return 1.
Return 0.
22.3.4.5 ZeroDateDuration ( )
The abstract operation ZeroDateDuration takes no arguments and returns a Date Duration Record. The returned Record represents a duration with length 0. It performs the following steps when called:
The abstract operation ValidateISODaysRange takes argument isoDate (an ISO Date Record) and returns either a normal completion containingunused or a throw completion. It checks that the given date is within the range of 108 days from the epoch. It performs the following steps when called:
If ISODateToEpochDays(isoDate.[[Year]], isoDate.[[Month]], isoDate.[[Day]]) is not in the inclusive interval from -108 to 108, throw a RangeError exception.
22.3.5.2 EpochDaysToEpochMilliseconds ( day, time )
The abstract operation EpochDaysToEpochMilliseconds takes arguments day (an integer) and time (an integer) and returns an integer. It calculates a number of milliseconds as in MakeDate, using mathematical values. It performs the following steps when called:
The abstract operation ISODateToEpochDays takes arguments year (an integer), month (an integer), and day (an integer) and returns an integer. It calculates a number of days as in MakeDay, using mathematical values. It performs the following steps when called:
Let resolvedYear be year + floor((month - 1) / 12).
An epoch nanoseconds count is an integer that represents an instant in time to nanosecond precision, as stored in the [[EpochNanoseconds]] internal slot of Temporal.Instant and Temporal.ZonedDateTime objects. It supports the same range as a time value but expressed in nanoseconds, from MinEpochNanoseconds to MaxEpochNanoseconds. There is no nanosecond equivalent of the time valueNaN; there is no representation for no specific instant.
The exact moment of midnight at the beginning of 1 January 1970 UTC is represented by the value 0. The maximum value is MaxEpochNanoseconds, and the minimum value is MinEpochNanoseconds.
The abstract operation CompareEpochNanoseconds takes arguments xEpochNanoseconds (an epoch nanoseconds count) and yEpochNanoseconds (an epoch nanoseconds count) and returns -1, 0, or 1. A return value of 0 means xEpochNanoseconds and yEpochNanoseconds are equal, 1 means xEpochNanoseconds comes after yEpochNanoseconds, and -1 means yEpochNanoseconds comes after xEpochNanoseconds. It performs the following steps when called:
If xEpochNanoseconds > yEpochNanoseconds, return 1.
If xEpochNanoseconds < yEpochNanoseconds, return -1.
The abstract operation DifferenceEpochNanoseconds takes arguments epochNanosecondsFrom (an epoch nanoseconds count), epochNanosecondsTwo (an epoch nanoseconds count), roundingIncrement (a positive integer), smallestUnit (a time unit), and roundingMode (a rounding mode) and returns an Internal Duration Record. It computes the difference between two epoch nanoseconds countsepochNanosecondsFrom and epochNanosecondsTo, and rounds the result according to the parameters roundingIncrement, smallestUnit, and roundingMode. It performs the following steps when called:
The abstract operation IsWithinEpochNanosecondsInterval takes argument epochNanoseconds (an integer) and returns a Boolean. It returns true if its argument is within the allowed range for an epoch nanoseconds count, and false otherwise. It performs the following steps when called:
The abstract operation InternalDurationSign takes argument internalDuration (an Internal Duration Record) and returns -1, 0, or 1. It returns 1 if the most significant non-zero field in the internalDuration argument is positive, and -1 if the most significant non-zero field is negative. If all of internalDuration's fields are zero, it returns 0. It performs the following steps when called:
The abstract operation ToInternalDurationRecord takes argument duration (a Temporal.Duration) and returns an Internal Duration Record. It converts duration into its internal form, for use in duration calculations that may involve time zones. The duration's days are kept separate and not converted into the [[Time]] field. It performs the following steps when called:
Let dateDuration be ! CreateDateDurationRecord(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]]).
Let timeDuration be ! TimeDurationFromComponents(duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
The abstract operation ToInternalDurationRecordWith24HourDays takes argument duration (a Temporal.Duration) and returns an Internal Duration Record. It converts duration into its internal form, for use in duration calculations that do not involve time zones. The duration's days are assumed to be uniformly 24 hours. The [[Days]] field of the Date Duration Record in the [[Date]] field of the returned Internal Duration Record is set to 0, and the [[Time]] field of the returned Internal Duration Record includes the days. It performs the following steps when called:
Let timeDuration be ! TimeDurationFromComponents(duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
The only calendar type that a conforming ECMA-262 implementation is required to support is the ISO 8601 calendar.
This section contains definitions specific to calendrical calculations in the ISO 8601 calendar.
The abstract operation CompareSurpasses takes arguments sign (-1 or 1), year (an integer), monthOrMonthCode (either an integer or a month code), day (an integer), and target (a Calendar Date Record) and returns a Boolean.
The return value indicates whether the ISO 8601 calendar date formed by year, monthOrMonthCode, and day, which need not exist, surpasses target in the direction denoted by sign.
It performs the following steps when called:
If year ≠ target.[[Year]], then
If sign × (year - target.[[Year]]) > 0, return true.
Else if monthOrMonthCode is a month code and monthOrMonthCode is not target.[[MonthCode]], then
If sign = 1 and monthOrMonthCode is lexicographically ordered after target.[[MonthCode]], return true.
If sign = -1 and target.[[MonthCode]] is lexicographically ordered after monthOrMonthCode, return true.
Else if monthOrMonthCode is an integer and monthOrMonthCode ≠ target.[[Month]], then
If sign × (monthOrMonthCode - target.[[Month]]) > 0, return true.
Else if day ≠ target.[[Day]], then
If sign × (day - target.[[Day]]) > 0, return true.
The abstract operation ISODateSurpasses takes arguments sign (-1 or 1), baseDate (an ISO Date Record), years (an integer), months (an integer), weeks (an integer), days (an integer), and isoDateTo (an ISO Date Record) and returns a Boolean.
The return value indicates whether the date isoDateFrom, the result of adding the duration denoted by years, months, weeks, and days to baseDate, surpasses isoDateTo in the direction denoted by sign.
If weeks and days are both zero, then isoDateFrom need not exist (for example, it could be February 30).
Note that this operation is specific to date difference calculations and is not the same as CompareISODate.
It performs the following steps when called:
This operation intentionally uses an overflow of "constrain" in step 10. As a result, this operation does not have the same meaning as Temporal.PlainDate.compare (22.11.2.3). It is only intended to be used inside CalendarDateUntil.
22.3.8.3 ISODaysInMonth ( year, month )
The abstract operation ISODaysInMonth takes arguments year (an integer) and month (an integer in the inclusive interval from 1 to 12) and returns a positive integer. It returns the number of days in the given year and month in the ISO 8601 calendar. It performs the following steps when called:
If month is one of 1, 3, 5, 7, 8, 10, or 12, return 31.
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 consists of the calendar week of year, which is the 1-based ordinal number of its calendar week within the corresponding week calendar year (which may differ from the calendar year by up to 1 in either direction).
The week calendar year is relative to the first day of a calendar-specific “epoch year”, as in the Calendar Date Record's [[Year]] field, not relative to an era as in [[EraYear]].
Both fields of the Year-Week Record are empty for calendars that do not have a well-defined week numbering system.
Year-Week Records have the fields listed in table Table 69.
The abstract operation ISOWeekOfYear takes argument isoDate (an ISO Date Record) and returns a Year-Week Record. It determines where a calendar day falls in the ISO 8601 week calendar and calculates its calendar week of year and week calendar year. It performs the following steps when called:
In the ISO 8601 week calendar (ISO 8601-1, Section 3.1.1.23), calendar week number 1 of a calendar year is the week including the first Thursday of that year (based on the principle that a week belongs to the same calendar year as the majority of its calendar days), which always includes January 4 and starts on the Monday on or immediately before then. Because of this, some calendar days of the first calendar week of a calendar year may be part of the preceding [proleptic Gregorian] date calendar year, and some calendar days of the last calendar week of a calendar year may be part of the following [proleptic Gregorian] date calendar year. See ISO 8601 for details.
Note 2
For example, week calendar year 2020 includes both 31 December 2019 (a Tuesday belonging to its calendar week 1) and 1 January 2021 (a Friday belonging to its calendar week 53).
22.3.8.6 ISODayOfYear ( isoDate )
The abstract operation ISODayOfYear takes argument isoDate (an ISO Date Record) and returns an integer. It returns the ISO 8601 calendar day of year of a calendar day, which is its 1-based ordinal number within its ISO 8601 calendar year. It performs the following steps when called:
Let epochDays be ISODateToEpochDays(isoDate.[[Year]], isoDate.[[Month]], isoDate.[[Day]]).
The abstract operation ISODayOfWeek takes argument isoDate (an ISO Date Record) and returns an integer. It returns the ISO 8601 calendar day of week of a calendar day, which is its 1-based ordinal position within the sequence of week calendar days that starts with Monday at 1 and ends with Sunday at 7. It performs the following steps when called:
Let epochDays be ISODateToEpochDays(isoDate.[[Year]], isoDate.[[Month]], isoDate.[[Day]]).
An ISO Date Record is a Record used to represent a calendar date that exists in the ISO 8601 calendar, although the year may be outside of the allowed range for Temporal.
ISO Date Records are produced by the abstract operation CreateISODateRecord.
For any ISO Date Record d, IsValidISODate(d.[[Year]], d.[[Month]], d.[[Day]]) must return true.
ISO Date Records have the fields listed in Table 70.
The number of the day of the month in the ISO 8601 calendar.
22.3.9.1 AddDaysToISODate ( isoDate, days )
The abstract operation AddDaysToISODate takes arguments isoDate (an ISO Date Record) and days (an integer) and returns an ISO Date Record.
It adds days to isoDate resulting in an ISO Date Record, by overflowing out-of-range month or day values into the next-highest unit.
This date may be outside the range given by ISODateWithinLimits.
It performs the following steps when called:
Let epochDays be ISODateToEpochDays(isoDate.[[Year]], isoDate.[[Month]], isoDate.[[Day]]) + days.
The abstract operation CompareISODate takes arguments xISODate (an ISO Date Record) and yISODate (an ISO Date Record) and returns -1, 0, or 1.
It performs a comparison of the two dates denoted by xISODate and yISODate according to ISO 8601 calendar arithmetic. A return value of 0 means xISODate and yISODate are equal, 1 means xISODate comes after yISODate, and -1 means yISODate comes after xISODate.
It performs the following steps when called:
If xISODate.[[Year]] > yISODate.[[Year]], return 1.
If xISODate.[[Year]] < yISODate.[[Year]], return -1.
If xISODate.[[Month]] > yISODate.[[Month]], return 1.
If xISODate.[[Month]] < yISODate.[[Month]], return -1.
If xISODate.[[Day]] > yISODate.[[Day]], return 1.
If xISODate.[[Day]] < yISODate.[[Day]], return -1.
If IsValidISODate(year, month, day) is false, throw a RangeError exception.
Return the ISO Date Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
22.3.9.4 ISODateToFields ( calendar, isoDate, type )
The abstract operation ISODateToFields takes arguments calendar (a known calendar type), isoDate (an ISO Date Record), and type (date, year-month, or month-day) and returns a Calendar Fields Record. It performs the following steps when called:
Let fields be the Calendar Fields Record {
[[Era]]: empty,
[[EraYear]]: empty,
[[Year]]: empty,
[[Month]]: empty,
[[MonthCode]]: empty,
[[Day]]: empty,
[[Hour]]: empty,
[[Minute]]: empty,
[[Second]]: empty,
[[Millisecond]]: empty,
[[Microsecond]]: empty,
[[Nanosecond]]: empty,
[[OffsetString]]: empty,
[[TimeZone]]: empty
}.
Set fields.[[MonthCode]] to calendarDate.[[MonthCode]].
If type is either month-day or date, then
Set fields.[[Day]] to calendarDate.[[Day]].
If type is either year-month or date, then
Set fields.[[Year]] to calendarDate.[[Year]].
Return fields.
22.3.9.5 ISODateWithinLimits ( isoDate )
The abstract operation ISODateWithinLimits takes argument isoDate (an ISO Date Record) and returns a Boolean. It returns true if the date in the ISO 8601 calendar given by the argument is within the representable range of Temporal.PlainDate, and false otherwise.
This operation is used primarily to validate the data being stored in the internal slots of Temporal.PlainDate and Temporal.PlainMonthDay objects.
Note
Deferring to ISODateTimeWithinLimits with an hour of 12 avoids trouble at the extremes of the representable range of Temporal.PlainDateTime, which stops just before midnight on each end.
The abstract operation IsValidISODate takes arguments year (an integer), month (an integer), and day (an integer) and returns a Boolean.
It returns true if its arguments form a date that exists in the ISO 8601 calendar, and false otherwise.
This includes dates that may fall outside of the allowed range for Temporal.
It performs the following steps when called:
The abstract operation RegulateISODate takes arguments year (an integer), month (an integer), day (an integer), and overflow ("constrain" or "reject") and returns either a normal completion containing an ISO Date Record or a throw completion.
It performs the overflow correction specified by overflow on the values year, month, and day, in order to arrive at an ISO Date Record.
If an ISO Date Record cannot be created from year, month, and day because the date formed by those values does not exist, the month and day are clamped to their respective valid ranges in the result if overflow is "constrain"; if it is "reject", an exception is thrown.
It performs the following steps when called:
If overflow is "constrain", then
Set month to the result of clampingmonth between 1 and 12.
An ISO Date-Time Record is a Record used to represent a date that exists in the ISO 8601 calendar, together with a clock time.
For any ISO Date-Time Record r, IsValidISODate(r.[[ISODate]].[[Year]], r.[[ISODate]].[[Month]], r.[[ISODate]].[[Day]]) must return true, and IsValidTime(r.[[Time]].[[Hour]], r.[[Time]].[[Minute]], r.[[Time]].[[Second]], r.[[Time]].[[Millisecond]], r.[[Time]].[[Microsecond]], r.[[Time]].[[Nanosecond]]) must return true.
It is not necessary for ISODateTimeWithinLimits(r) to return true.
An ISO Date-Time Record x is said to be earlier than another ISO Date-Time Record y if CompareISODateTime(x, y) = -1.
Likewise, x is later than y if CompareISODateTime(x, y) = 1.
ISO Date-Time Records have the fields listed in Table 71.
The abstract operation BalanceISODateTime takes arguments year (an integer), month (an integer), day (an integer), hour (an integer), minute (an integer), second (an integer), millisecond (an integer), microsecond (an integer), and nanosecond (an integer) and returns an ISO Date-Time Record. It performs the following steps when called:
Let balancedTime be BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond).
Let epochDays be ISODateToEpochDays(year, month, day) + balancedTime.[[Days]].
The abstract operation CompareISODateTime takes arguments xISODateTime (an ISO Date-Time Record) and yISODateTime (an ISO Date-Time Record) and returns -1, 0, or 1. It performs a comparison of two date-times according to ISO 8601 calendar arithmetic. A return value of 0 means xISODateTime and yISODateTime are equal, 1 means xISODateTime comes after yISODateTime, and -1 means yISODateTime comes after xISODateTime. It performs the following steps when called:
Let dateResult be CompareISODate(xISODateTime.[[ISODate]], yISODateTime.[[ISODate]]).
22.3.10.3 DifferenceISODateTime ( xISODateTime, yISODateTime, calendar, largestUnit )
The abstract operation DifferenceISODateTime takes arguments xISODateTime (an ISO Date-Time Record), yISODateTime (an ISO Date-Time Record), calendar (a known calendar type), and largestUnit (a Temporal unit) and returns an Internal Duration Record.
The returned Internal Duration Record contains the elapsed duration from a first date and time, until a second date and time, according to the reckoning of the given calendar.
The given date and time units are all in the ISO 8601 calendar.
It performs the following steps when called:
The abstract operation ISODateTimeWithinLimits takes argument isoDateTime (an ISO Date-Time Record) and returns a Boolean. It returns true if the combination of a date in the ISO 8601 calendar with a wall-clock time, given by the arguments, is within the representable range of Temporal.PlainDateTime, and false otherwise.
This operation is used primarily to validate the data being stored in the internal slots of Temporal.PlainDateTime objects. It performs the following steps when called:
If ISODateToEpochDays(isoDateTime.[[ISODate]].[[Year]], isoDateTime.[[ISODate]].[[Month]], isoDateTime.[[ISODate]].[[Day]]) is not in the inclusive interval from -108 to 108, return false.
22.3.10.5 RoundISODateTime ( isoDateTime, increment, unit, roundingMode )
The abstract operation RoundISODateTime takes arguments isoDateTime (an ISO Date-Time Record), increment (a positive integer), unit (either a time unit or "day"), and roundingMode (a rounding mode) and returns an ISO Date-Time Record. It rounds the time part of a combined date and time, carrying over any excess into the date part. It performs the following steps when called:
Lunisolar calendars may insert leap months into certain years, in order to reconcile the discrepancy between lunar cycles and the solar year.
For this reason, a particular month may not have the same ordinal number every year if a leap month is inserted before it.
A month code is a String that refers uniquely to a particular month, even one that is not present every year.
Month codes are lexicographically ordered according to the notional order of months in the year, even though not all may be present in any given year.
They conform to the following string format:
The month code for a month that is not a leap month at 1-based ordinal position index in a common year of the calendar (i.e., a year that is not a leap year) is the string-concatenation of "M" and ToZeroPaddedDecimalString(index, 2).
The month code for a leap month inserted after a month at 1-based ordinal position index in a common year of the calendar, is the string-concatenation of "M", ToZeroPaddedDecimalString(index, 2), and "L".
The month codes in the ISO 8601 calendar, which does not have leap months, are "M01" for January through "M12" for December.
Note
For example, in the Hebrew calendar, the month code of Adar (and Adar II, in leap years) is "M06" and the month code of Adar I (the leap month inserted before Adar II) is "M05L".
Theoretically, in a calendar with a leap month at the start of some years, the month code of that month would be "M00L".
The abstract operation CreateMonthCode takes arguments monthNumber (an integer in the inclusive interval from 0 to 99) and isLeapMonth (a Boolean) and returns a month code.
It creates a month code with the given month number and leap month flag.
Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M), numberPart, and the code unit 0x004C (LATIN CAPITAL LETTER L).
Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M) and numberPart.
22.3.11.2 ParseMonthCode ( argument )
The abstract operation ParseMonthCode takes argument argument (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[MonthNumber]] (an integer) and [[IsLeapMonth]] (a Boolean) or a throw completion.
It converts argument to a month code and parses it into its parts, or throws a TypeError if conversion to String fails, or throws a RangeError if the result is not a syntactically valid month code.
The month code is not guaranteed to be correct in the context of any particular calendar; for example, some calendars do not have leap months.
This section defines abstract operations for reading the properties of options Objects passed to Temporal functions.
For example, GetTemporalOverflowOption accesses the "overflow" property of an Object, ensures that it is one of the allowed values "constrain" or "reject", and returns one of the corresponding Enum specification types "constrain" or "reject".
The abstract operation GetDifferenceSettings takes arguments operation (since or until), options (an Object), unitGroup (date, time, or datetime), disallowedUnits (a List of Temporal units), fallbackSmallestUnit (a Temporal unit), and smallestLargestDefaultUnit (a Temporal unit) and returns either a normal completion containing a Record with fields [[SmallestUnit]] (a Temporal unit), [[LargestUnit]] (a Temporal unit), [[RoundingMode]] (a rounding mode), and [[RoundingIncrement]] (an integer in the inclusive interval from 1 to 109), or a throw completion. It reads unit and rounding options needed by difference operations. It performs the following steps when called:
Return the Record {
[[SmallestUnit]]: smallestUnit,
[[LargestUnit]]: largestUnit,
[[RoundingMode]]: roundingMode,
[[RoundingIncrement]]: roundingIncrement,
}.
22.3.12.2 GetDirectionOption ( options )
The abstract operation GetDirectionOption takes argument options (an Object) and returns either a normal completion containing either "next" or "previous", or a throw completion. It fetches and validates the "direction" property from options, throwing if absent. It performs the following steps when called:
If stringValue is not either "next"or "previous", throw a RangeError exception.
Return stringValue.
22.3.12.3 GetRoundingIncrementOption ( options )
The abstract operation GetRoundingIncrementOption takes argument options (an Object) and returns either a normal completion containing a positive integer in the inclusive interval from 1 to 109, or a throw completion.
It fetches and validates the "roundingIncrement" property from options, returning 1 if absent.
It performs the following steps when called:
The abstract operation GetRoundingModeOption takes arguments options (an Object) and fallback (a rounding mode) and returns either a normal completion containing a rounding mode, or a throw completion. It fetches and validates the "roundingMode" property from options, returning fallback if absent. It performs the following steps when called:
The abstract operation GetTemporalDisambiguationOption takes argument options (an Object) and returns either a normal completion containing either "compatible", "earlier", "later", or "reject", or a throw completion. It fetches and validates the "disambiguation" property of options, returning "compatible" if absent. It performs the following steps when called:
The abstract operation GetTemporalFractionalSecondDigitsOption takes argument options (an Object) and returns either a normal completion containing either auto or an integer in the inclusive interval from 0 to 9, or a throw completion. It fetches and validates the "fractionalSecondDigits" property from options, returning auto if absent. It performs the following steps when called:
Let digitsValue be ? Get(options, "fractionalSecondDigits").
The abstract operation GetTemporalOffsetOption takes arguments options (an Object) and fallback ("prefer", "use", "ignore", or "reject") and returns either a normal completion containing either "prefer", "use", "ignore", or "reject", or a throw completion. It fetches and validates the "offset" property of options, returning fallback if absent. It performs the following steps when called:
If stringValue is not one of "prefer", "use", "ignore", or "reject", throw a RangeError exception.
Return stringValue.
22.3.12.8 GetTemporalOverflowOption ( options )
The abstract operation GetTemporalOverflowOption takes argument options (an Object) and returns either a normal completion containing either "constrain" or "reject", or a throw completion. It fetches and validates the "overflow" property of options, returning "constrain" if absent. It performs the following steps when called:
If stringValue is not one of "constrain" or "reject", throw a RangeError exception.
Return stringValue.
22.3.12.9 GetTemporalRelativeToOption ( options )
The abstract operation GetTemporalRelativeToOption takes argument options (an Object) and returns either a normal completion containing a Record with fields [[PlainRelativeTo]] (a Temporal.PlainDate or empty) and [[ZonedRelativeTo]] (a Temporal.ZonedDateTime or empty), or a throw completion.
It examines the value of the relativeTo property of its options argument.
If the value is undefined, both the [[PlainRelativeTo]] and [[ZonedRelativeTo]] fields of the returned Record are empty.
If the value is not a String or an Object, it throws a TypeError.
Otherwise, it attempts to return a Temporal.ZonedDateTime instance in the [[ZonedRelativeTo]] field, or a Temporal.PlainDate instance in the [[PlainRelativeTo]] field, in order of preference, by converting the value.
If neither of those are possible, it throws a RangeError.
It performs the following steps when called:
Let epochNanoseconds be ? InterpretISODateTimeOffset(isoDate, time, offsetBehaviour, offsetNanoseconds, timeZone, "compatible", "reject", matchBehaviour).
The abstract operation GetTemporalShowCalendarNameOption takes argument options (an Object) and returns either a normal completion containing either "auto", "always", "never", or "critical", or a throw completion. It fetches and validates the "calendarName" property from options, returning "auto" if absent. It performs the following steps when called:
The abstract operation GetTemporalShowOffsetOption takes argument options (an Object) and returns either a normal completion containing either "auto" or "never", or a throw completion. It fetches and validates the "offset" property from options, returning "auto" if absent. It performs the following steps when called:
The abstract operation GetTemporalShowTimeZoneNameOption takes argument options (an Object) and returns either a normal completion containing either "auto", "never", or "critical", or a throw completion. It fetches and validates the "timeZoneName" property from options, returning "auto" if absent. It performs the following steps when called:
The abstract operation GetTemporalUnitValuedOption takes arguments options (an Object), key (a property key), and default (optional or required) and returns either a normal completion containing either a Temporal unit, no-unit, or "auto", or a throw completion. It attempts to read a Temporal unit from the specified property of options.
Both singular and plural unit names are accepted, but only the singular form is used internally.
If stringValue is either "year" or "years", return "year".
If stringValue is either "month" or "months", return "month".
If stringValue is either "week" or "weeks", return "week".
If stringValue is either "day" or "days", return "day".
If stringValue is either "hour" or "hours", return "hour".
If stringValue is either "minute" or "minutes", return "minute".
If stringValue is either "second" or "seconds", return "second".
If stringValue is either "milllisecond" or "millliseconds", return "milllisecond".
If stringValue is either "microsecond" or "microseconds", return "microsecond".
If stringValue is either "nanosecond" or "nanoseconds", return "nanosecond".
Throw a RangeError exception.
22.3.13 Rounding Modes and Increments
This section contains definitions pertaining to rounding increments and rounding modes.
Several Temporal Objects provide the capability of rounding a quantity to a given increment, following different rounding rules.
A rounding mode is one of the values in the “Rounding Mode” column of Table 72.
An unsigned rounding mode is one of infinity, zero, half-infinity, half-zero, or half-even.
The examples are illustrative of the unique behaviour of each option. ⬆️ means “resolves toward positive infinity”; ⬇️ means “resolves toward negative infinity”.
The abstract operation ApplyUnsignedRoundingMode takes arguments quantity (a mathematical value), lowerBound (a mathematical value), upperBound (a mathematical value), and unsignedRoundingMode (an unsigned rounding mode) and returns a mathematical value. It considers quantity, bounded below by lowerBound and above by upperBound, and returns either lowerBound or upperBound according to unsignedRoundingMode. It performs the following steps when called:
The abstract operation GetUnsignedRoundingMode takes arguments roundingMode (a rounding mode) and sign (negative or positive) and returns an unsigned rounding mode. It returns the unsigned rounding mode that should be applied to the absolute value of a number to produce the same result as if roundingMode were applied to the signed value of the number (negative if sign is negative, or positive otherwise). It performs the following steps when called:
If roundingMode is "ceil", then
If sign is positive, return infinity.
Return zero.
If roundingMode is "floor", then
If sign is positive, return zero.
Return infinity.
If roundingMode is "expand", return infinity.
If roundingMode is "trunc", return zero.
If roundingMode is "halfCeil", then
If sign is positive, return half-infinity.
Return half-zero.
If roundingMode is "halfFloor", then
If sign is positive, return half-zero.
Return half-infinity.
If roundingMode is "halfExpand", return half-infinity.
22.3.13.3 MaximumTemporalDurationRoundingIncrement ( unit )
The abstract operation MaximumTemporalDurationRoundingIncrement takes argument unit (a Temporal unit) and returns 24, 60, 1000, or no-maximum. Given a Temporal unit passed as input to methods that perform duration rounding calculations such as Temporal.Duration.prototype.round (22.15.3.20) or Temporal.PlainDate.prototype.until (22.11.3.25), it returns the maximum rounding increment for that unit, or no-maximum if there is no maximum. It performs the following steps when called:
If unit is "hour", return 24.
If unit is either "minute" or "second", return 60.
If unit is one of "millisecond", "microsecond", or "nanosecond", return 1000.
Return no-maximum.
22.3.13.4 NegateRoundingMode ( roundingMode )
The abstract operation NegateRoundingMode takes argument roundingMode (a rounding mode) and returns a rounding mode. It returns the correct rounding mode to use when rounding the negative of a value that was originally given with roundingMode. It performs the following steps when called:
If roundingMode is "ceil", return "floor".
If roundingMode is "floor", return "ceil".
If roundingMode is "halfCeil", return "halfFloor".
If roundingMode is "halfFloor", return "halfCeil".
The abstract operation RoundNumberToIncrement takes arguments quantity (a mathematical value), increment (a positive integer), and roundingMode (a rounding mode) and returns an integer. It rounds quantity to the nearest multiple of increment, up or down according to roundingMode. It performs the following steps when called:
The abstract operation RoundNumberToIncrementAsIfPositive takes arguments quantity (a mathematical value), increment (a positive integer), and roundingMode (a rounding mode) and returns an integer.
It rounds quantity to the nearest multiple of increment, up or down according to roundingMode, but always as if quantity were positive.
For example, "floor" and "trunc" behave identically.
This is used when rounding exact times, where “rounding down” conceptually always means towards the beginning of time, even if the time is expressed as a negative amount of time relative to an epoch.
It performs the following steps when called:
The abstract operation ValidateTemporalRoundingIncrement takes arguments increment (a positive integer), dividend (a positive integer), and inclusive (a Boolean) and returns either a normal completion containingunused or a throw completion.
It checks whether increment evenly divides dividend, throwing a RangeError if it does not.
dividend must be divided into more than one part unless inclusive is true.
It performs the following steps when called:
22.3.14.1 Add24HourDaysToTimeDuration ( timeDuration, days )
The abstract operation Add24HourDaysToTimeDuration takes arguments timeDuration (a time duration) and days (an integer) and returns either a normal completion containing a time duration or a throw completion.
It returns a time duration that is the sum of timeDuration and the number of 24-hour days indicated by days, throwing an error if the result is not within the range of a time duration.
This operation is not used in time zone arithmetic such as Temporal.Duration.prototype.round (22.15.3.20) with a Temporal.ZonedDateTime instance as the relativeTo parameter, since those days may not be 24 hours long.
It performs the following steps when called:
The abstract operation RoundTimeDurationToIncrement takes arguments timeDuration (a time duration), increment (a positive integer), and roundingMode (a rounding mode) and returns either a normal completion containing a time duration or a throw completion. It rounds the total number of nanoseconds in the time durationtimeDuration to the nearest multiple of increment, up or down according to roundingMode. It performs the following steps when called:
The abstract operation TimeDurationSign takes argument timeDuration (a time duration) and returns -1, 0, or 1. It returns 0 if the duration is zero, or ±1 depending on the sign of the duration. It performs the following steps when called:
If timeDuration < 0, return -1.
If timeDuration > 0, return 1.
Return 0.
22.3.14.9 TotalTimeDuration ( timeDuration, unit )
The abstract operation TotalTimeDuration takes arguments timeDuration (a time duration) and unit (either a time unit or "day") and returns a mathematical value. It returns the total number of unit in duration. It performs the following steps when called:
This operation cannot be implemented directly using floating-point arithmetic when 𝔽(timeDuration) is not a safe integer. The division can be implemented in C++ with the __float128 type if the compiler supports it, or with software emulation such as in the SoftFP library.
22.3.15 Time Records
A Time Record is a Record used to represent a valid clock time, together with a number of overflow days such as might occur in BalanceTime.
For any Time Record t, IsValidTime(t.[[Hour]], t.[[Minute]], t.[[Second]], t.[[Millisecond]], t.[[Microsecond]], t.[[Nanosecond]]) must return true.
Most uses of Time Records ignore the [[Days]] field. The [[Days]] field is only used to indicate an overflow number of days when performing arithmetic in BalanceTime and RoundTime.
The abstract operation AddTime takes arguments time (a Time Record) and timeDuration (a time duration) and returns a Time Record. It performs the following steps when called:
The abstract operation BalanceTime takes arguments hour (an integer), minute (an integer), second (an integer), millisecond (an integer), microsecond (an integer), and nanosecond (an integer) and returns a Time Record. It performs the following steps when called:
Set microsecond to microsecond + floor(nanosecond / 1000).
The abstract operation CompareTimeRecord takes arguments xTime (a Time Record) and yTime (a Time Record) and returns -1, 0, or 1. It compares the two given times, returning -1 if yTime comes later in the day than xTime, 1 if xTime comes later in the day than yTime, and 0 if they are the same. It performs the following steps when called:
If xTime.[[Hour]] > yTime.[[Hour]], return 1.
If xTime.[[Hour]] < yTime.[[Hour]], return -1.
If xTime.[[Minute]] > yTime.[[Minute]], return 1.
If xTime.[[Minute]] < yTime.[[Minute]], return -1.
If xTime.[[Second]] > yTime.[[Second]], return 1.
If xTime.[[Second]] < yTime.[[Second]], return -1.
If xTime.[[Millisecond]] > yTime.[[Millisecond]], return 1.
If xTime.[[Millisecond]] < yTime.[[Millisecond]], return -1.
If xTime.[[Microsecond]] > yTime.[[Microsecond]], return 1.
If xTime.[[Microsecond]] < yTime.[[Microsecond]], return -1.
If xTime.[[Nanosecond]] > yTime.[[Nanosecond]], return 1.
If xTime.[[Nanosecond]] < yTime.[[Nanosecond]], return -1.
If IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
Return the Time Record { [[Days]]: deltaDays, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.
22.3.15.5 DifferenceTime ( timeFrom, timeTo )
The abstract operation DifferenceTime takes arguments timeFrom (a Time Record) and timeTo (a Time Record) and returns a time duration. It returns the elapsed duration from a first wall-clock time, until a second wall-clock time. It performs the following steps when called:
Let hours be timeTo.[[Hour]] - timeFrom.[[Hour]].
Let minutes be timeTo.[[Minute]] - timeFrom.[[Minute]].
Let seconds be timeTo.[[Second]] - timeFrom.[[Second]].
Let milliseconds be timeTo.[[Millisecond]] - timeFrom.[[Millisecond]].
Let microseconds be timeTo.[[Microsecond]] - timeFrom.[[Microsecond]].
Let nanoseconds be timeTo.[[Nanosecond]] - timeFrom.[[Nanosecond]].
Let timeDuration be ! TimeDurationFromComponents(hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
The abstract operation IsValidTime takes arguments hour (an integer), minute (an integer), second (an integer), millisecond (an integer), microsecond (an integer), and nanosecond (an integer) and returns a Boolean.
It returns true if its arguments form a valid time of day, and false otherwise.
Leap seconds are not taken into account.
It performs the following steps when called:
If millisecond is not in the inclusive interval from 0 to 999, return false.
If microsecond is not in the inclusive interval from 0 to 999, return false.
If nanosecond is not in the inclusive interval from 0 to 999, return false.
Return true.
22.3.15.7 MidnightTimeRecord ( )
The abstract operation MidnightTimeRecord takes no arguments and returns a Time Record. The returned Record denotes the wall-clock time of midnight. It performs the following steps when called:
Return the Time Record {
[[Days]]: 0,
[[Hour]]: 0,
[[Minute]]: 0,
[[Second]]: 0,
[[Millisecond]]: 0,
[[Microsecond]]: 0,
[[Nanosecond]]: 0
}.
22.3.15.8 NoonTimeRecord ( )
The abstract operation NoonTimeRecord takes no arguments and returns a Time Record. The returned Record denotes the wall-clock time of noon. It performs the following steps when called:
Return the Time Record {
[[Days]]: 0,
[[Hour]]: 12,
[[Minute]]: 0,
[[Second]]: 0,
[[Millisecond]]: 0,
[[Microsecond]]: 0,
[[Nanosecond]]: 0
}.
The abstract operation RegulateTime takes arguments hour (an integer), minute (an integer), second (an integer), millisecond (an integer), microsecond (an integer), nanosecond (an integer), and overflow ("constrain" or "reject") and returns either a normal completion containing a Time Record or a throw completion.
It applies the correction given by overflow to the given time.
If overflow is "constrain", out-of-range values are clamped.
If overflow is "reject", a RangeError is thrown if any values are out of range.
It performs the following steps when called:
If overflow is "constrain", then
Set hour to the result of clampinghour between 0 and 23.
Set minute to the result of clampingminute between 0 and 59.
Set second to the result of clampingsecond between 0 and 59.
Set millisecond to the result of clampingmillisecond between 0 and 999.
Set microsecond to the result of clampingmicrosecond between 0 and 999.
Set nanosecond to the result of clampingnanosecond between 0 and 999.
22.3.15.10 RoundTime ( time, increment, unit, roundingMode )
The abstract operation RoundTime takes arguments time (a Time Record), increment (a positive integer), unit (either a time unit or "day"), and roundingMode (a rounding mode) and returns a Time Record. It rounds a time to the given increment. It performs the following steps when called:
The abstract operation TimeRecordToString takes arguments time (a Time Record) and precision (either an integer in the inclusive interval from 0 to 9, minute, or auto) and returns a String. It formats the given time as an ISO 8601 string, to the precision specified by precision. It performs the following steps when called:
A partial Time Record is a Record used to represent input used for constructing a Temporal.PlainTime object (such as input passed to Temporal.PlainTime.prototype.with, 22.12.3.11), in which it is not required that all the fields be present or in the correct interval.
Partial Time Records have the fields listed in Table 74.
Additionally, partial Time Records must have at least one field that is not empty.
The abstract operation ToPartialTimeRecord takes arguments temporalTimeLike (an Object) and completeness (partial or complete) and returns either a normal completion containing a partial Time Record or a throw completion. It performs the following steps when called:
If completeness is complete, then
Let result be the partial Time Record {
[[Hour]]: 0,
[[Minute]]: 0,
[[Second]]: 0,
[[Millisecond]]: 0,
[[Microsecond]]: 0,
[[Nanosecond]]: 0
}.
Else,
Let result be the partial Time Record {
[[Hour]]: empty,
[[Minute]]: empty,
[[Second]]: empty,
[[Millisecond]]: empty,
[[Microsecond]]: empty,
[[Nanosecond]]: empty
}.
Time is reckoned using multiple units.
A Temporal unit is one of "year", "month", "week", "day", "hour", "minute", "second", "millisecond", "microsecond", or "nanosecond".
A calendar unit is one of "year", "month", or "week".
A date unit is either a calendar unit or "day", and a time unit is one of "hour", "minute", "second", "millisecond", "microsecond", or "nanosecond".
22.3.16.1 DefaultTemporalLargestUnit ( duration )
The abstract operation DefaultTemporalLargestUnit takes argument duration (a Temporal.Duration) and returns a Temporal unit. It implements the logic used in the Temporal.Duration.prototype.round method (22.15.3.20) and elsewhere, where the largestUnit option, if not given explicitly, is set to the largest-magnitude non-zero unit, or "nanosecond" for a zero-length duration. It performs the following steps when called:
If duration.[[Years]] ≠ 0, return "year".
If duration.[[Months]] ≠ 0, return "month".
If duration.[[Weeks]] ≠ 0, return "week".
If duration.[[Days]] ≠ 0, return "day".
If duration.[[Hours]] ≠ 0, return "hour".
If duration.[[Minutes]] ≠ 0, return "minute".
If duration.[[Seconds]] ≠ 0, return "second".
If duration.[[Milliseconds]] ≠ 0, return "millisecond".
If duration.[[Microseconds]] ≠ 0, return "microsecond".
The abstract operation LargerOfTwoTemporalUnits takes arguments xUnit (a Temporal unit) and yUnit (a Temporal unit) and returns a Temporal unit. Given two Temporal units, it returns the larger of the two units. It performs the following steps when called:
If xUnit is "year" or yUnit is "year", return "year".
If xUnit is "month" or yUnit is "month", return "month".
If xUnit is "week" or yUnit is "week", return "week".
If xUnit is "day" or yUnit is "day", return "day".
If xUnit is "hour" or yUnit is "hour", return "hour".
If xUnit is "minute" or yUnit is "minute", return "minute".
If xUnit is "second" or yUnit is "second", return "second".
If xUnit is "millisecond" or yUnit is "millisecond", return "millisecond".
If xUnit is "microsecond" or yUnit is "microsecond", return "microsecond".
Return "nanosecond".
22.3.16.3 TemporalUnitLength ( unit )
The abstract operation TemporalUnitLength takes argument unit (a time unit or "day") and returns a positive integer. It returns the length of unit in nanoseconds. It performs the following steps when called:
The length of the "day"unit is considered to be NanosecondsPerDay.
Note that changes in the UTC offset of a time zone may result in longer or shorter days, so care should be taken when using this value in the context of Temporal.ZonedDateTime arithmetic.
The abstract operation ValidateTemporalUnitValue takes arguments value (either a Temporal unit, no-unit, or "auto") and unitGroup (date, time, or datetime) and optional argument extraValues (a List of either Temporal units or "auto") and returns either a normal completion containingunused or a throw completion. It validates that the result of GetTemporalUnitValuedOption is covered by the union of unitGroup, extraValues, and « no-unit ». It performs the following steps when called:
If value is no-unit, return unused.
If extraValues is present and extraValues contains value, return unused.
If value is a date unit and unitGroup is either date or datetime, return unused.
If value is a time unit and unitGroup is either time or datetime, return unused.
Throw a RangeError exception.
22.3.17 IsPartialTemporalObject ( value )
The abstract operation IsPartialTemporalObject takes argument value (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It determines whether value is a suitable input for one of the plain or zoned Temporal types' with() methods (22.11.3.23, 22.10.3.25, 22.14.3.6, 22.12.3.11, 22.13.3.13, 22.9.3.31): it must be an Object, it must not be an instance of one of those Temporal types, and it must not have a calendar or timeZone property. It performs the following steps when called:
If value has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, return false.
If timeZoneProperty is not undefined, return false.
Return true.
22.4 Parsing ISO 8601 / RFC 9557 Strings
Several operations in this section are intended to parse strings representing a date, a time, a duration, or a combined date and time.
For the purposes of these operations, a valid ISO 8601 / RFC 9557 string is defined as a String that can be generated by one of the goal elements of the following grammar.
22.4.1 ISO 8601 / RFC 9557 Grammar
This grammar is adapted from the ABNF grammar of the ISO 8601 date-time format that is given in appendix A of RFC 3339, augmented with the grammar of annotations in section 4.1 of RFC 9557.
RFC 9557 and ISO 8601 are similar, but ISO 8601 defines a number of optional deviations that are allowed “by agreement between the communicating parties”.
The following is a list of deviations supported by this grammar:
Only the calendar date format is supported, not the weekdate or ordinal date format.
Fractional parts may have 1 through 9 decimal places.
In time representations, only seconds are allowed to have a fractional part.
In duration representations, only hours, minutes, and seconds are allowed to have a fractional part.
A space may be used to separate the date and time in a combined date / time representation, but not in a duration (e.g., "1970-01-01 00:00Z" is valid but "P1D 1H" is not).
Alphabetic designators may be in lower or upper case (e.g., "1970-01-01t00:00Z" and "1970-01-01T00:00z" and "pT1m" are valid).
Period or comma may be used as the decimal separator (e.g., "PT1,00H" is a valid representation of a 1-hour duration).
UTC offsets of "-00:00" and "-0000" and "-00" are allowed, and all mean the same thing as "+00:00".
UTC offsets may have seconds and up to 9 sub-second fractional digits (e.g., "1970-01-01T00:00:00+00:00:00.123456789" is valid).
The constituent date, time, and UTC offset parts of a combined representation may each independently use basic format (with no separator symbols) or extended format (with mandatory - or : separators), as long as each such part is itself in either basic format or extended format (e.g., "1970-01-01T012345" and "19700101T01:23:45" are valid but "1970-0101T012345" and "1970-01-01T0123:45" are not).
When parsing a date representation without a day for a Temporal.PlainYearMonth, the expression is allowed to be in basic format (with no separator symbols).
A duration specifier of "W" (weeks) can be combined with any of the other specifiers (e.g., "P1M1W1D" is valid).
Anything else described by ISO 8601 as requiring mutual agreement between communicating parties, is disallowed.
In addition to the above deviations, any number of conforming RFC 9557 suffixes in square brackets are allowed.
However, the only recognized suffixes are time zone and BCP 47 calendar.
Others are ignored, unless they are prefixed with !, in which case they are rejected.
Note that the suffix keys, although they look similar, are not the same as keys in RFC 6067.
In particular, keys are lowercase-only.
A RFC 9557 Time Zone Parse Record is a Record used to represent the result of parsing the representation of the time zone in an ISO 8601 / RFC 9557 string.
RFC 9557 Time Zone Parse Records have the fields listed in Table 75.
For any ISO Date-Time Parse Record r, IsValidISODate(r.[[Year]], r.[[Month]], r.[[Day]]) must return true, or, if r.[[Year]] is empty, IsValidISODate(1972, r.[[Month]], r.[[Day]]) must return true.
It is not necessary for the represented date and time to be within the range given by ISODateTimeWithinLimits.
ISO Date-Time Parse Records have the fields listed in Table 77.
The abstract operation ParseISODateTime takes arguments isoString (a String) and allowedFormats (all, any-date-time, zoned-date-time, plain-date-time, instant, time, year-month, or month-day) and returns either a normal completion containing an ISO Date-Time Parse Record or a throw completion. It parses the argument as an ISO 8601 / RFC 9557 string and returns a Record representing each date and time component as a distinct field. It performs the following steps when called:
If parseResult is not a Parse Node, throw a RangeError exception.
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.
If yearAbsent is true, let yearReturn be empty; else let yearReturn be yearMV.
Return the ISO Date-Time Parse Record {
[[Year]]: yearReturn,
[[Month]]: monthMV,
[[Day]]: dayMV,
[[Time]]: time,
[[TimeZone]]: timeZoneResult,
[[Calendar]]: calendar
}.
If timeZoneResult.[[OffsetString]] is not empty, return ? ParseTimeZoneIdentifier(timeZoneResult.[[OffsetString]]).
Throw a RangeError exception.
22.4.9 ParseTimeZoneIdentifier ( identifier )
The abstract operation ParseTimeZoneIdentifier takes argument identifier (a String) and returns either a normal completion containing a Time Zone Identifier Parse Record, or a throw completion.
It parses identifier to determine whether it identifies an offset time zone or named time zone. If identifier is syntactically invalid, a RangeError will be thrown.
It performs the following steps when called:
The abstract operation FormatCalendarAnnotation takes arguments id (a known calendar type) and showCalendar ("auto", "always", "never", or "critical") and returns a String.
It returns a String with a calendar annotation suitable for concatenating to the end of an ISO 8601 / RFC 9557 string.
Depending on the given id and value of showCalendar, the String may be empty if no calendar annotation need be included.
It performs the following steps when called:
If showCalendar is "never", return the empty String.
If showCalendar is "auto" and id is "iso8601", return the empty String.
If showCalendar is "critical", let flag be "!"; else, let flag be the empty String.
The abstract operation FormatDateTimeUTCOffsetRounded takes argument offsetNanoseconds (an integer in the interval from -NanosecondsPerDay (exclusive) to NanosecondsPerDay (exclusive)) and returns a String. It rounds offsetNanoseconds to the nearest minute boundary and formats the rounded value into a ±HH:MM format, to support available named time zones that may have sub-minute offsets. It performs the following steps when called:
The abstract operation FormatFractionalSeconds takes arguments subSecondNanoseconds (an integer in the inclusive interval from 0 to 999999999) and precision (either an integer in the inclusive interval from 0 to 9 or auto) and returns a String.
If precision = 0, or precision is auto and subSecondNanoseconds = 0, then an empty String will be returned.
Otherwise, the output will be a decimal point followed by a sequence of fractional seconds digits, truncated to precision digits or (if precision is auto) to the last non-zero digit.
It performs the following steps when called:
If precision is auto, then
If subSecondNanoseconds = 0, return the empty String.
Set fractionString to the substring of fractionString from 0 to precision.
Return the string-concatenation of the code unit 0x002E (FULL STOP) and fractionString.
22.5.4 FormatISODateTime ( isoDateTime, calendar, precision, showCalendar )
The abstract operation FormatISODateTime takes arguments isoDateTime (an ISO Date-Time Record), calendar (a known calendar type), precision (either an integer in the inclusive interval from 0 to 9, minute, or auto), and showCalendar ("auto", "always", "never", or "critical") and returns a String. It formats an ISO Date-Time Record into an ISO 8601 / RFC 9557 string, to the precision specified by precision. It performs the following steps when called:
Let yearString be PadISOYear(isoDateTime.[[ISODate]].[[Year]]).
Let timeString be FormatTimeString(isoDateTime.[[Time]].[[Hour]], isoDateTime.[[Time]].[[Minute]], isoDateTime.[[Time]].[[Second]], subSecondNanoseconds, precision).
Return the string-concatenation of yearString, the code unit 0x002D (HYPHEN-MINUS), monthString, the code unit 0x002D (HYPHEN-MINUS), dayString, 0x0054 (LATIN CAPITAL LETTER T), timeString, and calendarString.
The abstract operation FormatOffsetTimeZoneIdentifier takes argument offsetMinutes (an integer in the inclusive interval from -1439 to 1439) and optional argument style (separated or unseparated) and returns an offset time zone identifier.
It formats a UTC offset, in minutes, into a UTC offset string.
If style is separated or not present, then the output will be formatted like ±HH:MM and the return value identifier can be parsed with ParseText(identifier, NormalizedUTCOffset).
If style is unseparated, then the output will be formatted like ±HHMM.
It performs the following steps when called:
If offsetMinutes ≥ 0, let sign be the code unit 0x002B (PLUS SIGN); else let sign be the code unit 0x002D (HYPHEN-MINUS).
The abstract operation FormatTimeString takes arguments 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), subSecondNanoseconds (an integer in the inclusive interval from 0 to 999999999), and precision (either an integer in the inclusive interval from 0 to 9, minute, or auto) and optional argument style (separated or unseparated) and returns a String.
It formats a collection of unsigned time components into a String, truncating units as necessary, and separating hours, minutes, and seconds with colons unless style is unseparated.
The output will be formatted like HH:MM or HHMM if precision is minute.
Otherwise, the output will be formatted like HH:MM:SS or HHMMSS if precision = 0, or subSecondNanoseconds = 0 and precision is auto.
Otherwise, the output will be formatted like HH:MM:SS.fff… or HHMMSS.fff… where fff is a sequence of fractional seconds digits, truncated to precision digits or (if precision is auto) to the last non-zero digit.
It performs the following steps when called:
If style is present and style is unseparated, let separator be the empty String; else let separator be ":".
The abstract operation FormatUTCOffsetNanoseconds takes argument offsetNanoseconds (an integer in the interval from -NanosecondsPerDay (exclusive) to NanosecondsPerDay (exclusive)) and returns a String.
If the offset represents an integer number of minutes, then the output will be formatted like ±HH:MM.
Otherwise, the output will be formatted like ±HH:MM:SS or (if the offset does not evenly divide into seconds) ±HH:MM:SS.fff… where the fff part is a sequence of at least 1 and at most 9 fractional seconds digits with no trailing zeroes.
It performs the following steps when called:
If offsetNanoseconds ≥ 0, let sign be the code unit 0x002B (PLUS SIGN); else let sign be the code unit 0x002D (HYPHEN-MINUS).
Let absoluteNanoseconds be abs(offsetNanoseconds).
The abstract operation PadISOYear takes argument isoYear (an integer) and returns a String. It returns a String representation of isoYear suitable for inclusion in an ISO 8601 string, either in 4-digit format or 6-digit format with sign. It performs the following steps when called:
The abstract operation ToSecondsStringPrecisionRecord takes arguments smallestUnit ("minute", "second", "millisecond", "microsecond", "nanosecond", or no-unit) and fractionalDigitCount (either an integer in the inclusive interval from 0 to 9 or auto) and returns a Record with fields [[Precision]] (either an integer in the inclusive interval from 0 to 9, minute, or auto), [[Unit]] (one of "minute", "second", "millisecond", "microsecond", or "nanosecond"), and [[Increment]] (one of 1, 10, or 100).
The returned Record represents details for serializing minutes and seconds to a String subject to the specified smallestUnit or (when smallestUnit is no-unit) fractionalDigitCount digits after the decimal point in the seconds.
Its [[Precision]] field is either that count of digits, the value auto signifying that there should be no insignificant trailing zeroes, or the value minute signifying that seconds should not be included at all.
Its [[Unit]] field is the most precise unit that can contribute to the string, and its [[Increment]] field indicates the rounding increment that should be applied to that unit.
It performs the following steps when called:
If smallestUnit is "minute", return the Record {
[[Precision]]: minute,
[[Unit]]: "minute",
[[Increment]]: 1
}.
If smallestUnit is "second", return the Record {
[[Precision]]: 0,
[[Unit]]: "second",
[[Increment]]: 1
}.
If smallestUnit is "millisecond", return the Record {
[[Precision]]: 3,
[[Unit]]: "millisecond",
[[Increment]]: 1
}.
If smallestUnit is "microsecond", return the Record {
[[Precision]]: 6,
[[Unit]]: "microsecond",
[[Increment]]: 1
}.
If smallestUnit is "nanosecond", return the Record {
[[Precision]]: 9,
[[Unit]]: "nanosecond",
[[Increment]]: 1
}.
If fractionalDigitCount is auto, return the Record {
[[Precision]]: auto,
[[Unit]]: "nanosecond",
[[Increment]]: 1
}.
If fractionalDigitCount = 0, return the Record {
[[Precision]]: 0,
[[Unit]]: "second",
[[Increment]]: 1
}.
If fractionalDigitCount is in the inclusive interval from 1 to 3, return the Record {
[[Precision]]: fractionalDigitCount,
[[Unit]]: "millisecond",
[[Increment]]: 103 - fractionalDigitCount
}.
If fractionalDigitCount is in the inclusive interval from 4 to 6, return the Record {
[[Precision]]: fractionalDigitCount,
[[Unit]]: "microsecond",
[[Increment]]: 106 - fractionalDigitCount
}.
The abstract operation SystemUTCEpochNanoseconds takes no arguments and returns an epoch nanoseconds count. It performs the following steps when called:
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.Instant behaviour must
include a super call to the %Temporal.Instant%constructor to create and initialize subclass
instances with the necessary internal slots.
22.8.1.1 Temporal.Instant ( epochNanoseconds )
This function performs the following steps when called:
If NewTarget is undefined, throw a TypeError exception.
Let epochNanosecondsMV be ℝ(? ToBigInt(epochNanoseconds)).
The initial value of the %Symbol.toStringTag% property is the String "Temporal.Instant".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.8.3.3 get Temporal.Instant.prototype.epochMilliseconds
Temporal.Instant.prototype.epochMilliseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.8.3.4 get Temporal.Instant.prototype.epochNanoseconds
Temporal.Instant.prototype.epochNanoseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as instant1 > instant2 would fall back to being equivalent to instant1.toString() > instant2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.Instant.compare (22.8.2.5), Temporal.Instant.prototype.equals (22.8.3.10), and/or Temporal.Instant.prototype.toString (22.8.3.11).
Assert: Either parsed.[[TimeZone]].[[OffsetString]] is not empty or parsed.[[TimeZone]].[[Z]] is true, but not both.
If parsed.[[TimeZone]].[[Z]] is true, let offsetNanoseconds be 0; else let offsetNanoseconds be ! ParseDateTimeUTCOffset(parsed.[[TimeZone]].[[OffsetString]]).
The abstract operation TemporalInstantToString takes arguments instant (a Temporal.Instant), timeZone (either an available time zone identifier or undefined), and precision (either an integer in the inclusive interval from 0 to 9, minute, or auto) and returns a String. It formats instant as an ISO 8601 / RFC 9557 string, to the precision specified by precision, using the UTC offset of timeZone, or Z if timeZone is undefined. It performs the following steps when called:
Let outputTimeZone be timeZone.
If outputTimeZone is undefined, set outputTimeZone to "UTC".
Let epochNanoseconds be instant.[[EpochNanoseconds]].
Let isoDateTime be GetISODateTimeFor(outputTimeZone, epochNanoseconds).
Let dateTimeString be FormatISODateTime(isoDateTime, "iso8601", precision, "never").
Let settings be ? GetDifferenceSettings(operation, resolvedOptions, time, « », "nanosecond", "second").
Let internalDuration be DifferenceEpochNanoseconds(instant.[[EpochNanoseconds]], other.[[EpochNanoseconds]], settings.[[RoundingIncrement]], settings.[[SmallestUnit]], settings.[[RoundingMode]]).
A Temporal.ZonedDateTime object is an Object referencing a fixed point in time with nanoseconds precision, and containing String identifiers corresponding to a particular time zone and calendar system.
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.ZonedDateTime behaviour must
include a super call to the %Temporal.ZonedDateTime%constructor to create and initialize subclass
instances with the necessary internal slots.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
The initial value of the %Symbol.toStringTag% property is the String "Temporal.ZonedDateTime".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.9.3.3 get Temporal.ZonedDateTime.prototype.calendarId
Temporal.ZonedDateTime.prototype.calendarId is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.4 get Temporal.ZonedDateTime.prototype.timeZoneId
Temporal.ZonedDateTime.prototype.timeZoneId is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.ZonedDateTime.prototype.era is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Let isoDateTime be GetISODateTimeFor(zonedDateTime.[[TimeZone]], zonedDateTime.[[EpochNanoseconds]]).
Let result be CalendarISOToDate(zonedDateTime.[[Calendar]], isoDateTime.[[ISODate]]).[[Era]].
If result is empty, return undefined.
Return result.
22.9.3.6 get Temporal.ZonedDateTime.prototype.eraYear
Temporal.ZonedDateTime.prototype.eraYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.7 get Temporal.ZonedDateTime.prototype.year
Temporal.ZonedDateTime.prototype.year is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.8 get Temporal.ZonedDateTime.prototype.month
Temporal.ZonedDateTime.prototype.month is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.9 get Temporal.ZonedDateTime.prototype.monthCode
Temporal.ZonedDateTime.prototype.monthCode is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.10 get Temporal.ZonedDateTime.prototype.day
Temporal.ZonedDateTime.prototype.day is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.11 get Temporal.ZonedDateTime.prototype.hour
Temporal.ZonedDateTime.prototype.hour is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.12 get Temporal.ZonedDateTime.prototype.minute
Temporal.ZonedDateTime.prototype.minute is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.13 get Temporal.ZonedDateTime.prototype.second
Temporal.ZonedDateTime.prototype.second is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.14 get Temporal.ZonedDateTime.prototype.millisecond
Temporal.ZonedDateTime.prototype.millisecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.15 get Temporal.ZonedDateTime.prototype.microsecond
Temporal.ZonedDateTime.prototype.microsecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.16 get Temporal.ZonedDateTime.prototype.nanosecond
Temporal.ZonedDateTime.prototype.nanosecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.17 get Temporal.ZonedDateTime.prototype.epochMilliseconds
Temporal.ZonedDateTime.prototype.epochMilliseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.18 get Temporal.ZonedDateTime.prototype.epochNanoseconds
Temporal.ZonedDateTime.prototype.epochNanoseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.19 get Temporal.ZonedDateTime.prototype.dayOfWeek
Temporal.ZonedDateTime.prototype.dayOfWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.20 get Temporal.ZonedDateTime.prototype.dayOfYear
Temporal.ZonedDateTime.prototype.dayOfYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.21 get Temporal.ZonedDateTime.prototype.weekOfYear
Temporal.ZonedDateTime.prototype.weekOfYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.22 get Temporal.ZonedDateTime.prototype.yearOfWeek
Temporal.ZonedDateTime.prototype.yearOfWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.23 get Temporal.ZonedDateTime.prototype.hoursInDay
Temporal.ZonedDateTime.prototype.hoursInDay is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.24 get Temporal.ZonedDateTime.prototype.daysInWeek
Temporal.ZonedDateTime.prototype.daysInWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.25 get Temporal.ZonedDateTime.prototype.daysInMonth
Temporal.ZonedDateTime.prototype.daysInMonth is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.26 get Temporal.ZonedDateTime.prototype.daysInYear
Temporal.ZonedDateTime.prototype.daysInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.27 get Temporal.ZonedDateTime.prototype.monthsInYear
Temporal.ZonedDateTime.prototype.monthsInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.28 get Temporal.ZonedDateTime.prototype.inLeapYear
Temporal.ZonedDateTime.prototype.inLeapYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.29 get Temporal.ZonedDateTime.prototype.offsetNanoseconds
Temporal.ZonedDateTime.prototype.offsetNanoseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.9.3.30 get Temporal.ZonedDateTime.prototype.offset
Temporal.ZonedDateTime.prototype.offset is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as zonedDateTime1 > zonedDateTime2 would fall back to being equivalent to zonedDateTime1.toString() > zonedDateTime2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.ZonedDateTime.compare (22.9.2.3), Temporal.ZonedDateTime.prototype.equals (22.9.3.40), and/or Temporal.ZonedDateTime.prototype.toString (22.9.3.41).
Let epochNanoseconds be ? InterpretISODateTimeOffset(isoDate, time, offsetBehaviour, offsetNanoseconds, timeZone, disambiguation, offsetOption, matchBehaviour).
The abstract operation TemporalZonedDateTimeToString takes arguments zonedDateTime (a Temporal.ZonedDateTime), precision (either an integer in the inclusive interval from 0 to 9, minute, or auto), showCalendar ("auto", "always", "never", or "critical"), showTimeZone ("auto", "never", or "critical"), and showOffset ("auto" or "never") and optional arguments increment (a positive integer), unit (a time unit but not "hour"), and roundingMode (a rounding mode) and returns a String.
It returns an ISO 8601 / RFC 9557 string representation of its argument, including a time zone name annotation and calendar annotation, which are extensions to the ISO 8601 format.
It performs the following steps when called:
If increment is not present, set increment to 1.
If unit is not present, set unit to "nanosecond".
If roundingMode is not present, set roundingMode to "trunc".
Let epochNanoseconds be zonedDateTime.[[EpochNanoseconds]].
Set epochNanoseconds to RoundEpochNanoseconds(epochNanoseconds, increment, unit, roundingMode).
If showTimeZone is "critical", let flag be "!"; else let flag be the empty String.
Let timeZoneString be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), flag, timeZone, and the code unit 0x005D (RIGHT SQUARE BRACKET).
If largestUnit is a time unit, return DifferenceEpochNanoseconds(epochNanosecondsFrom, epochNanosecondsTo, roundingIncrement, smallestUnit, roundingMode).
Let difference be ? DifferenceZonedDateTime(epochNanosecondsFrom, epochNanosecondsTo, timeZone, calendar, largestUnit).
If smallestUnit is "nanosecond" and roundingIncrement = 1, return difference.
Let internalDuration be DifferenceEpochNanoseconds(zonedDateTime.[[EpochNanoseconds]], other.[[EpochNanoseconds]], settings.[[RoundingIncrement]], settings.[[SmallestUnit]], settings.[[RoundingMode]]).
NOTE: To calculate differences in two different time zones, settings.[[LargestUnit]] must be a time unit, because day lengths can vary between time zones due to daylight saving time and other UTC offset shifts.
If TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, throw a RangeError exception.
It determines the epoch nanoseconds count in timeZone corresponding to the given calendar date and time, and the given UTC offset in nanoseconds.
In the case of more than one possible epoch nanoseconds count, or no possible epoch nanoseconds count, an answer is determined using offsetBehaviour, disambiguation and offsetOption.
As a special case when parsing ISO 8601 / RFC 9557 strings which are only required to specify time zone offsets to minutes precision, if matchBehaviour is match-minutes, then a value for offsetNanoseconds that is rounded to the nearest minute will be accepted in those cases where offsetNanoseconds is compared against timeZone's offset.
If matchBehaviour is match-exactly, then this does not happen.
A Temporal.PlainDateTime object is an Object that contains integers corresponding to a particular year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond, as well as a calendar type used to interpret those integers in a particular calendar.
Temporal.PlainDateTime objects can represent points in time within 24 hours, exclusive, of the limits of epoch nanoseconds counts.
This ensures that a Temporal.Instant object can be converted into a Temporal.PlainDateTime object using any time zone.
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.PlainDateTime behaviour must
include a super call to the %Temporal.PlainDateTime%constructor to create and initialize subclass
instances with the necessary internal slots.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
The initial value of the %Symbol.toStringTag% property is the String "Temporal.PlainDateTime".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.10.3.3 get Temporal.PlainDateTime.prototype.calendarId
Temporal.PlainDateTime.prototype.calendarId is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.4 get Temporal.PlainDateTime.prototype.era
Temporal.PlainDateTime.prototype.era is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Let result be CalendarISOToDate(plainDateTime.[[Calendar]], plainDateTime.[[ISODateTime]].[[ISODate]]).[[Era]].
If result is empty, return undefined.
Return result.
22.10.3.5 get Temporal.PlainDateTime.prototype.eraYear
Temporal.PlainDateTime.prototype.eraYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.6 get Temporal.PlainDateTime.prototype.year
Temporal.PlainDateTime.prototype.year is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.7 get Temporal.PlainDateTime.prototype.month
Temporal.PlainDateTime.prototype.month is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.8 get Temporal.PlainDateTime.prototype.monthCode
Temporal.PlainDateTime.prototype.monthCode is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.9 get Temporal.PlainDateTime.prototype.day
Temporal.PlainDateTime.prototype.day is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.10 get Temporal.PlainDateTime.prototype.hour
Temporal.PlainDateTime.prototype.hour is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.11 get Temporal.PlainDateTime.prototype.minute
Temporal.PlainDateTime.prototype.minute is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.12 get Temporal.PlainDateTime.prototype.second
Temporal.PlainDateTime.prototype.second is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.13 get Temporal.PlainDateTime.prototype.millisecond
Temporal.PlainDateTime.prototype.millisecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.14 get Temporal.PlainDateTime.prototype.microsecond
Temporal.PlainDateTime.prototype.microsecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.15 get Temporal.PlainDateTime.prototype.nanosecond
Temporal.PlainDateTime.prototype.nanosecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.16 get Temporal.PlainDateTime.prototype.dayOfWeek
Temporal.PlainDateTime.prototype.dayOfWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.17 get Temporal.PlainDateTime.prototype.dayOfYear
Temporal.PlainDateTime.prototype.dayOfYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.18 get Temporal.PlainDateTime.prototype.weekOfYear
Temporal.PlainDateTime.prototype.weekOfYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.19 get Temporal.PlainDateTime.prototype.yearOfWeek
Temporal.PlainDateTime.prototype.yearOfWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.20 get Temporal.PlainDateTime.prototype.daysInWeek
Temporal.PlainDateTime.prototype.daysInWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.21 get Temporal.PlainDateTime.prototype.daysInMonth
Temporal.PlainDateTime.prototype.daysInMonth is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.22 get Temporal.PlainDateTime.prototype.daysInYear
Temporal.PlainDateTime.prototype.daysInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.23 get Temporal.PlainDateTime.prototype.monthsInYear
Temporal.PlainDateTime.prototype.monthsInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.10.3.24 get Temporal.PlainDateTime.prototype.inLeapYear
Temporal.PlainDateTime.prototype.inLeapYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as plainDateTime1 > plainDateTime2 would fall back to being equivalent to plainDateTime1.toString() > plainDateTime2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.PlainDateTime.compare (22.10.2.3), Temporal.PlainDateTime.prototype.equals (22.10.3.33), and/or Temporal.PlainDateTime.prototype.toString (22.10.3.34).
Assert: fields.[[Hour]], fields.[[Minute]], fields.[[Second]], fields.[[Millisecond]], fields.[[Microsecond]], and fields.[[Nanosecond]] are not empty.
Let time be ? RegulateTime(fields.[[Hour]], fields.[[Minute]], fields.[[Second]], fields.[[Millisecond]], fields.[[Microsecond]], fields.[[Nanosecond]], overflow).
A Temporal.PlainDate object is an Object that contains integers corresponding to a
particular year, month, and day in the ISO8601 calendar, as well as a calendar type used to
interpret those integers in a particular calendar.
Temporal.PlainDate objects can represent the date portion of any Temporal.PlainDateTime object.
This ensures that a Temporal.PlainDateTime object can always be converted into a Temporal.PlainDate object using any Temporal.PlainTime, but not vice versa.
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.PlainDate behaviour must
include a super call to the %Temporal.PlainDate%constructor to create and initialize subclass
instances with the necessary internal slots.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
The initial value of the %Symbol.toStringTag% property is the String "Temporal.PlainDate".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.11.3.3 get Temporal.PlainDate.prototype.calendarId
Temporal.PlainDate.prototype.calendarId is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.PlainDate.prototype.era is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Let result be CalendarISOToDate(plainDate.[[Calendar]], plainDate.[[ISODate]]).[[Era]].
If result is empty, return undefined.
Return result.
22.11.3.5 get Temporal.PlainDate.prototype.eraYear
Temporal.PlainDate.prototype.eraYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.PlainDate.prototype.year is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.PlainDate.prototype.month is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.8 get Temporal.PlainDate.prototype.monthCode
Temporal.PlainDate.prototype.monthCode is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.PlainDate.prototype.day is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.10 get Temporal.PlainDate.prototype.dayOfWeek
Temporal.PlainDate.prototype.dayOfWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.11 get Temporal.PlainDate.prototype.dayOfYear
Temporal.PlainDate.prototype.dayOfYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.12 get Temporal.PlainDate.prototype.weekOfYear
Temporal.PlainDate.prototype.weekOfYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.13 get Temporal.PlainDate.prototype.yearOfWeek
Temporal.PlainDate.prototype.yearOfWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.14 get Temporal.PlainDate.prototype.daysInWeek
Temporal.PlainDate.prototype.daysInWeek is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.15 get Temporal.PlainDate.prototype.daysInMonth
Temporal.PlainDate.prototype.daysInMonth is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.16 get Temporal.PlainDate.prototype.daysInYear
Temporal.PlainDate.prototype.daysInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.17 get Temporal.PlainDate.prototype.monthsInYear
Temporal.PlainDate.prototype.monthsInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.11.3.18 get Temporal.PlainDate.prototype.inLeapYear
Temporal.PlainDate.prototype.inLeapYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
NOTE: The call to CalendarYearMonthFromFields is necessary in order to create a PlainYearMonth object with the [[Day]] field of the [[ISODate]] internal slot set correctly.
NOTE: The call to CalendarMonthDayFromFields is necessary in order to create a PlainMonthDay object with the [[Year]] field of the [[ISODate]] internal slot set correctly.
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as plainDate1 > plainDate2 would fall back to being equivalent to plainDate1.toString() > plainDate2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.PlainDate.compare (22.11.2.3), Temporal.PlainDate.prototype.equals (22.11.3.27), and/or Temporal.PlainDate.prototype.toString` (22.11.3.30).
22.11.4 Properties of Temporal.PlainDate Instances
The abstract operation TemporalDateToString takes arguments temporalDate (a Temporal.PlainDate) and showCalendar ("auto", "always", "never", or "critical") and returns a String. It formats temporalDate to an ISO 8601 / RFC 9557 string. It performs the following steps when called:
Let year be PadISOYear(temporalDate.[[ISODate]].[[Year]]).
Let dateDuration be ! CreateDateDurationRecord(internalDuration.[[Date]].[[Years]], internalDuration.[[Date]].[[Months]], internalDuration.[[Date]].[[Weeks]], days).
A Temporal.PlainTime object is an Object that contains integers corresponding to a particular hour, minute,
second, millisecond, microsecond, and nanosecond.
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.PlainTime behaviour must
include a super call to the %Temporal.PlainTime%constructor to create and initialize subclass
instances with the necessary internal slots.
The initial value of the %Symbol.toStringTag% property is the String "Temporal.PlainTime".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.12.3.3 get Temporal.PlainTime.prototype.hour
Temporal.PlainTime.prototype.hour is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.PlainTime.prototype.minute is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.PlainTime.prototype.second is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.12.3.6 get Temporal.PlainTime.prototype.millisecond
Temporal.PlainTime.prototype.millisecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.12.3.7 get Temporal.PlainTime.prototype.microsecond
Temporal.PlainTime.prototype.microsecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.12.3.8 get Temporal.PlainTime.prototype.nanosecond
Temporal.PlainTime.prototype.nanosecond is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as plainTime1 > plainTime2 would fall back to being equivalent to plainTime1.toString() > plainTime2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.PlainTime.compare (22.12.2.3), Temporal.PlainTime.prototype.equals (22.12.3.15), and/or Temporal.PlainTime.prototype.toString (22.12.3.16).
22.12.4 Properties of Temporal.PlainTime Instances
Set result to ? RegulateTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], overflow).
The abstract operation AddDurationToTime takes arguments operation (add or subtract), temporalTime (a Temporal.PlainTime), and temporalDurationLike (an ECMAScript language value) and returns either a normal completion containing a Temporal.PlainTime or a throw completion. It adds/subtracts temporalDurationLike to/from temporalTime, returning a point in time that is in the future/past relative to temporalTime. It performs the following steps when called:
A Temporal.PlainYearMonth object is an Object that contains integers corresponding to a particular year and month in a particular calendar.
Temporal.PlainYearMonth objects can represent any month that contains a day that a Temporal.PlainDate can represent.
This ensures that a Temporal.PlainDate object can always be converted into a Temporal.PlainYearMonth object.
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.PlainYearMonth behaviour must
include a super call to the %Temporal.PlainYearMonth%constructor to create and initialize subclass
instances with the necessary internal slots.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
The initial value of the %Symbol.toStringTag% property is the String "Temporal.PlainYearMonth".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.13.3.3 get Temporal.PlainYearMonth.prototype.calendarId
Temporal.PlainYearMonth.prototype.calendarId is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.4 get Temporal.PlainYearMonth.prototype.era
Temporal.PlainYearMonth.prototype.era is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Let result be CalendarISOToDate(plainYearMonth.[[Calendar]], plainYearMonth.[[ISODate]]).[[Era]].
If result is empty, return undefined.
Return result.
22.13.3.5 get Temporal.PlainYearMonth.prototype.eraYear
Temporal.PlainYearMonth.prototype.eraYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.6 get Temporal.PlainYearMonth.prototype.year
Temporal.PlainYearMonth.prototype.year is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.7 get Temporal.PlainYearMonth.prototype.month
Temporal.PlainYearMonth.prototype.month is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.8 get Temporal.PlainYearMonth.prototype.monthCode
Temporal.PlainYearMonth.prototype.monthCode is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.9 get Temporal.PlainYearMonth.prototype.daysInYear
Temporal.PlainYearMonth.prototype.daysInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.10 get Temporal.PlainYearMonth.prototype.daysInMonth
Temporal.PlainYearMonth.prototype.daysInMonth is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.11 get Temporal.PlainYearMonth.prototype.monthsInYear
Temporal.PlainYearMonth.prototype.monthsInYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.13.3.12 get Temporal.PlainYearMonth.prototype.inLeapYear
Temporal.PlainYearMonth.prototype.inLeapYear is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as plainYearMonth1 > plainYearMonth2 would fall back to being equivalent to plainYearMonth1.toString() > plainYearMonth2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.PlainYearMonth.compare (22.13.2.3), Temporal.PlainYearMonth.prototype.equals (22.13.3.18), and/or Temporal.PlainYearMonth.prototype.toString (22.13.3.19).
The only specified use of this slot is for distinguishing Temporal.PlainYearMonth instances from other objects.
[[ISODate]]
An ISO Date Record.
The [[Day]] field is used by the calendar in the [[Calendar]] slot to disambiguate if the [[Year]] and [[Month]] fields are not sufficient to uniquely identify a year and month in that calendar.
Set result to ISODateToFields(calendar, isoDate, year-month).
NOTE: The following operation is called with "constrain" regardless of overflow, in order for the calendar to store a canonical value in the [[Day]] field of the [[ISODate]] internal slot of the result.
The abstract operation TemporalYearMonthToString takes arguments yearMonth (a Temporal.PlainYearMonth) and showCalendar ("auto", "always", "never", or "critical") and returns a String. It formats yearMonth as an ISO 8601 / RFC 9557 string. It performs the following steps when called:
Let year be PadISOYear(yearMonth.[[ISODate]].[[Year]]).
Set duration to ? RoundRelativeDuration(duration, originEpochNanoseconds, destEpochNanoseconds, isoDateTime, no-time-zone, calendar, settings.[[LargestUnit]], settings.[[RoundingIncrement]], settings.[[SmallestUnit]], settings.[[RoundingMode]]).
An ISO Year-Month Record is a Record used to represent a valid month in the ISO 8601 calendar, although the year may be outside of the allowed range for Temporal.
ISO Year-Month Records have the fields listed in Table 84.
The abstract operation BalanceISOYearMonth takes arguments year (an integer) and month (an integer) and returns an ISO Year-Month Record. It performs the following steps when called:
The abstract operation ISOYearMonthWithinLimits takes argument isoDate (an ISO Date Record) and returns a Boolean. It returns true if its argument represents a month within the range that a Temporal.PlainYearMonth object can represent, and false otherwise. It performs the following steps when called:
If isoDate.[[Year]] is not in the inclusive interval from -271821 to 275760, return false.
If isoDate.[[Year]] = -271821 and isoDate.[[Month]] < 4, return false.
If isoDate.[[Year]] = 275760 and isoDate.[[Month]] > 9, return false.
Return true.
22.14 Temporal.PlainMonthDay Objects
A Temporal.PlainMonthDay object is an Object that contains integers corresponding to a particular month and day in a particular calendar.
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.PlainMonthDay behaviour must
include a super call to the %Temporal.PlainMonthDay%constructor to create and initialize subclass
instances with the necessary internal slots.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
The initial value of the %Symbol.toStringTag% property is the String "Temporal.PlainMonthDay".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.14.3.3 get Temporal.PlainMonthDay.prototype.calendarId
Temporal.PlainMonthDay.prototype.calendarId is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.14.3.4 get Temporal.PlainMonthDay.prototype.monthCode
Temporal.PlainMonthDay.prototype.monthCode is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.14.3.5 get Temporal.PlainMonthDay.prototype.day
Temporal.PlainMonthDay.prototype.day is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in ECMA-402.
Otherwise, the following specification of this method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as plainMonthDay1 > plainMonthDay2 would fall back to being equivalent to plainMonthDay1.toString() > plainMonthDay2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.PlainDate.compare (22.11.2.3) on the corresponding Temporal.PlainDate objects, Temporal.PlainMonthDay.prototype.equals (22.14.3.7), and/or Temporal.PlainMonthDay.prototype.toString (22.14.3.8).
The only specified use of this slot is for distinguishing Temporal.PlainMonthDay instances from other objects.
[[ISODate]]
An ISO Date Record.
The [[Year]] field is used by the calendar in the [[Calendar]] slot to disambiguate if the [[Month]] and [[Day]] fields are not sufficient to uniquely identify a month and day in that calendar.
Set result to ISODateToFields(calendar, isoDate, month-day).
NOTE: The following operation is called with "constrain" regardless of overflow, in order for the calendar to store a canonical value in the [[Year]] field of the [[ISODate]] internal slot of the result.
The abstract operation TemporalMonthDayToString takes arguments monthDay (a Temporal.PlainMonthDay) and showCalendar ("auto", "always", "never", or "critical") and returns a String. It formats monthDay into an ISO 8601 / RFC 9557 string. It performs the following steps when called:
is not intended to be called as a function and will throw an exception when called in that manner.
may be used as the value of an extends clause of a class definition.
Subclass constructors that intend to inherit the specified Temporal.Duration behaviour must
include a super call to the %Temporal.Duration%constructor to create and initialize subclass
instances with the necessary internal slots.
If xDurationLike.[[Years]] = yDurationLike.[[Years]], and xDurationLike.[[Months]] = yDurationLike.[[Months]], and xDurationLike.[[Weeks]] = yDurationLike.[[Weeks]], and xDurationLike.[[Days]] = yDurationLike.[[Days]], and xDurationLike.[[Hours]] = yDurationLike.[[Hours]], and xDurationLike.[[Minutes]] = yDurationLike.[[Minutes]], and xDurationLike.[[Seconds]] = yDurationLike.[[Seconds]], and xDurationLike.[[Milliseconds]] = yDurationLike.[[Milliseconds]], and xDurationLike.[[Microseconds]] = yDurationLike.[[Microseconds]], and xDurationLike.[[Nanoseconds]] = yDurationLike.[[Nanoseconds]], then
Return +0𝔽.
Let zonedRelativeTo be relativeToRecord.[[ZonedRelativeTo]].
Let plainRelativeTo be relativeToRecord.[[PlainRelativeTo]].
The initial value of the %Symbol.toStringTag% property is the String "Temporal.Duration".
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
22.15.3.3 get Temporal.Duration.prototype.years
Temporal.Duration.prototype.years is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.months is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.weeks is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.days is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.hours is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.minutes is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.seconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.15.3.10 get Temporal.Duration.prototype.milliseconds
Temporal.Duration.prototype.milliseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.15.3.11 get Temporal.Duration.prototype.microseconds
Temporal.Duration.prototype.microseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
22.15.3.12 get Temporal.Duration.prototype.nanoseconds
Temporal.Duration.prototype.nanoseconds is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.sign is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Temporal.Duration.prototype.blank is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
Let relativeEpochNanoseconds be zonedRelativeTo.[[EpochNanoseconds]].
Let targetEpochNanoseconds be ? AddZonedDateTime(relativeEpochNanoseconds, timeZone, calendar, internalDuration, "constrain").
Set internalDuration to ? DifferenceZonedDateTimeWithRounding(relativeEpochNanoseconds, targetEpochNanoseconds, timeZone, calendar, largestUnit, roundingIncrement, smallestUnit, roundingMode).
If largestUnit is a date unit, set largestUnit to "hour".
Let targetDateTime be the ISO Date-Time Record { [[ISODate]]: targetDate, [[Time]]: targetTime }.
Set internalDuration to ? DifferencePlainDateTimeWithRounding(isoDateTime, targetDateTime, calendar, largestUnit, roundingIncrement, smallestUnit, roundingMode).
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Temporal.Duration.prototype.toLocaleString method as specified in ECMA-402.
Otherwise, the following specification of the Temporal.Duration.prototype.toLocaleString method is used.
The meanings of the optional parameters to this method are defined in ECMA-402; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
This method performs the following steps when called:
Throw a TypeError exception.
Note
This method always throws, because in the absence of valueOf(), expressions with arithmetic operators such as duration1 > duration2 would fall back to being equivalent to duration1.toString() > duration2.toString().
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to Temporal.Duration.compare (22.15.2.3) and/or Temporal.Duration.prototype.toString (22.15.3.22).
A float64-representable integer is an integer that is exactly representable as a Number.
That is, for a float64-representable integer x, it must hold that ℝ(𝔽(x)) = x.
Note
The use of float64-representable integers here is intended so that implementations can store Temporal.Duration fields using 64-bit floating-point values.
However, duration arithmetic is not performed in 64-bit floating-point space.
In this specification, duration arithmetic is performed on mathematical values, but a correct implementation could use 96-bit integer arithmetic for all but the division operations in NudgeToCalendarUnit and TotalTimeDuration.
The [[Years]], [[Months]], and [[Weeks]] slots are further limited, so a conforming implementation could store them using 32-bit unsigned integers if the overall duration sign is stored separately. Every 32-bit unsigned integer is also a float64-representable integer.
The abstract operation CreateNegatedTemporalDuration takes argument duration (a Temporal.Duration) and returns a Temporal.Duration. It returns a new Temporal.Duration instance that is the negation of duration. It performs the following steps when called:
The abstract operation TemporalDurationFromInternal takes arguments internalDuration (an Internal Duration Record) and largestUnit (a Temporal unit) and returns either a normal completion containing a Temporal.Duration, or a throw completion.
It converts internalDuration back into the form of a Temporal.Duration object, with each component stored separately, at the end of a duration calculation.
The time units are balanced up to largestUnit.
The conversion may be lossy if largestUnit is "millisecond", "microsecond", or "nanosecond".
In that case, the internal slots of the returned Temporal.Duration may contain unsafe (but float64-representable) integers.
The result of a lossy conversion may be outside the allowed range for Durations, even if the input was not.
It performs the following steps when called:
Let days, hours, minutes, seconds, milliseconds, and microseconds be 0.
NOTE: When largestUnit is "millisecond", "microsecond", or "nanosecond", milliseconds, microseconds, or nanoseconds may be an unsafe integer. In this case, care must be taken when implementing the calculation using floating point arithmetic. It can be implemented in C++ using std::fma(). String manipulation will also give an exact result, since the multiplication is by a power of 10.
The abstract operation TemporalDurationToString takes arguments duration (a Temporal.Duration) and precision (either an integer in the inclusive interval from 0 to 9 or auto) and returns a String. It returns a String which is the ISO 8601 representation of duration, with the number of decimal places in the seconds value controlled by precision. It performs the following steps when called:
the code units of the decimal representation of abs(duration.[[Minutes]])
the code unit 0x004D (LATIN CAPITAL LETTER M)
Let zeroMinutesAndHigher be false.
If DefaultTemporalLargestUnit(duration) is one of "second", "millisecond", "microsecond", or "nanosecond", set zeroMinutesAndHigher to true.
Let secondsDuration be ! TimeDurationFromComponents(0, 0, duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
If secondsDuration ≠ 0, or zeroMinutesAndHigher is true, or precision is not auto, then
Let signPart be the code unit 0x002D (HYPHEN-MINUS) if sign < 0, and otherwise the empty String.
Let result be the string-concatenation of signPart, the code unit 0x0050 (LATIN CAPITAL LETTER P) and datePart.
If timePart is not the empty String, then
Set result to the string-concatenation of result, the code unit 0x0054 (LATIN CAPITAL LETTER T), and timePart.
Return result.
22.15.5.6 AddDurations ( operation, duration, other )
The abstract operation AddDurations takes arguments operation (add or subtract), duration (a Temporal.Duration), and other (an ECMAScript language value) and returns either a normal completion containing a Temporal.Duration or a throw completion.
It adds or subtracts the components of a second duration other to or from those of a first duration duration, resulting in a longer or shorter duration, unless calendar calculations would be required, in which case it throws an exception.
It balances the result, ensuring that no mixed signs remain.
It performs the following steps when called:
The abstract operation DurationSign takes argument duration (a Temporal.Duration) and returns -1, 0, or 1. It returns 1 if the most significant non-zero field in the duration argument is positive, and -1 if the most significant non-zero field is negative. If all of duration's fields are zero, it returns 0. It performs the following steps when called:
For each value value of « duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]] », do
The abstract operation IsValidDuration takes arguments years (an integer), months (an integer), weeks (an integer), days (an integer), hours (an integer), minutes (an integer), seconds (an integer), milliseconds (an integer), microseconds (an integer), and nanoseconds (an integer) and returns a Boolean. It returns true if its arguments form valid input from which to construct a Temporal.Duration, and false otherwise. It performs the following steps when called:
Let sign be 0.
For each value value of « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds », do
NOTE: The above step cannot be implemented directly using 64-bit floating-point arithmetic. Multiplying by 10-3, 10-6, and 10-9 respectively may be imprecise when milliseconds, microseconds, or nanoseconds is an unsafe integer. The step can be implemented by using 128-bit integers and performing all arithmetic on nanosecond values. It could also be implemented in C++ with an implementation of std::remquo() with sufficient bits in the quotient. String manipulation will also give an exact result, since the multiplication is by a power of 10.
A partial Duration Record is a Record used to represent input used for construction of a Temporal.Duration object (such as input passed to Temporal.Duration.prototype.with, 22.15.3.15), in which it is not required that all the fields be specified.
Partial Duration Records have the fields listed in Table 87.
Additionally, Partial Duration Records must have at least one field that is not empty.
If days is not undefined, set result.[[Days]] to ? SnapToInteger(days, reject).
Let hours be ? Get(temporalDurationLike, "hours").
If hours is not undefined, set result.[[Hours]] to ? SnapToInteger(hours, reject).
Let microseconds be ? Get(temporalDurationLike, "microseconds").
If microseconds is not undefined, set result.[[Microseconds]] to ? SnapToInteger(microseconds, reject).
Let milliseconds be ? Get(temporalDurationLike, "milliseconds").
If milliseconds is not undefined, set result.[[Milliseconds]] to ? SnapToInteger(milliseconds, reject).
Let minutes be ? Get(temporalDurationLike, "minutes").
If minutes is not undefined, set result.[[Minutes]] to ? SnapToInteger(minutes, reject).
Let months be ? Get(temporalDurationLike, "months").
If months is not undefined, set result.[[Months]] to ? SnapToInteger(months, reject).
Let nanoseconds be ? Get(temporalDurationLike, "nanoseconds").
If nanoseconds is not undefined, set result.[[Nanoseconds]] to ? SnapToInteger(nanoseconds, reject).
Let seconds be ? Get(temporalDurationLike, "seconds").
If seconds is not undefined, set result.[[Seconds]] to ? SnapToInteger(seconds, reject).
Let weeks be ? Get(temporalDurationLike, "weeks").
If weeks is not undefined, set result.[[Weeks]] to ? SnapToInteger(weeks, reject).
Let years be ? Get(temporalDurationLike, "years").
If years is not undefined, set result.[[Years]] to ? SnapToInteger(years, reject).
If years is undefined, and months is undefined, and weeks is undefined, and days is undefined, and hours is undefined, and minutes is undefined, and seconds is undefined, and milliseconds is undefined, and microseconds is undefined, and nanoseconds is undefined, throw a TypeError exception.
Let progress be (destEpochNanoseconds - startEpochNanoseconds) / (endEpochNanoseconds - startEpochNanoseconds).
Let total be innerBound + progress × increment × sign.
NOTE: The above two steps cannot be implemented directly using floating-point arithmetic. This division can be implemented as if expressing total as the quotient of two time durations (which may not be safe integers), performing all other calculations before the division, and finally performing one division operation with a floating-point result for total. The division can be implemented in C++ with the __float128 type if the compiler supports it, or with software emulation such as in the SoftFP library.
Let nudgedEpochNanoseconds be endEpochNanoseconds.
Else,
Let resultDuration be startDuration.
Let nudgedEpochNanoseconds be startEpochNanoseconds.
Let nudgeResult be Duration Nudge Result Record { [[Duration]]: resultDuration, [[NudgedEpochNanoseconds]]: nudgedEpochNanoseconds, [[DidExpandCalendarUnit]]: didExpandCalendarUnit }.
Return the Record { [[NudgeResult]]: nudgeResult, [[Total]]: total }.
22.15.5.14 NudgeToZonedTime ( sign, duration, isoDateTime, timeZone, calendar, increment, unit, roundingMode )
The abstract operation NudgeToZonedTime takes arguments sign (-1 or 1), duration (an Internal Duration Record), isoDateTime (an ISO Date-Time Record), timeZone (an available time zone identifier), calendar (a known calendar type), increment (a positive integer), unit (a time unit), and roundingMode (a rounding mode) and returns either a normal completion containing a Duration Nudge Result Record or a throw completion.
It implements rounding a duration to an increment of a time unit, accounting for the case where the rounding causes the time to exceed the total time within a day, which may be influenced by UTC offset changes in the time zone.
This operation is used in duration rounding arithmetic that takes time zones into account, such as that performed by Temporal.ZonedDateTime.prototype.until (22.9.3.37).
It performs the following steps when called:
Let start be ? CalendarDateAdd(calendar, isoDateTime.[[ISODate]], duration.[[Date]], "constrain").
Let startDateTime be the ISO Date-Time Record { [[ISODate]]: start, [[Time]]: isoDateTime.[[Time]] }.
Return the Duration Nudge Result Record { [[Duration]]: resultDuration, [[NudgedEpochNanoseconds]]: nudgedEpochNanoseconds, [[DidExpandCalendarUnit]]: didRoundBeyondDay }.
Return the Duration Nudge Result Record { [[Duration]]: resultDuration, [[NudgedEpochNanoseconds]]: nudgedEpochNanoseconds, [[DidExpandCalendarUnit]]: didExpandDays }.
Let record be ? NudgeToCalendarUnit(sign, duration, originEpochNanoseconds, destEpochNanoseconds, isoDateTime, timeZone, calendar, increment, smallestUnit, roundingMode).
Let nudgeResult be record.[[NudgeResult]].
Else if timeZone is not no-time-zone, then
Let nudgeResult be ? NudgeToZonedTime(sign, duration, isoDateTime, timeZone, calendar, increment, smallestUnit, roundingMode).
Else,
Let nudgeResult be ? NudgeToDayOrTime(duration, destEpochNanoseconds, largestUnit, increment, smallestUnit, roundingMode).
Set duration to nudgeResult.[[Duration]].
If nudgeResult.[[DidExpandCalendarUnit]] is true and smallestUnit is not "year" or "week", then
Set duration to ? BubbleRelativeDuration(sign, duration, nudgeResult.[[NudgedEpochNanoseconds]], isoDateTime, timeZone, calendar, largestUnit, startUnit).
Return duration.
22.15.5.18 TotalRelativeDuration ( duration, originEpochNanoseconds, destEpochNanoseconds, isoDateTime, timeZone, calendar, unit )