Stage 2 Draft / September 18, 2020

Temporal proposal

Introduction

TBD

1 The Temporal Object

The Temporal object:

  • is the intrinsic object %Temporal%.
  • is the initial value of the "Temporal" property of the global object.
  • is an ordinary object.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.
  • is not a function object.
  • does not have a [[Construct]] internal method; it cannot be used as a constructor with the new operator.
  • does not have a [[Call]] internal method; it cannot be invoked as a function.

1.1 Constructor Properties of the Temporal Object

1.1.1 Temporal.Absolute ( . . . )

See 7.

1.1.2 Temporal.DateTime ( . . . )

See 5.

1.1.3 Temporal.Date ( . . . )

See 3.

1.1.4 Temporal.Time ( . . . )

See 4.

1.1.5 Temporal.YearMonth ( . . . )

See 8.

1.1.6 Temporal.MonthDay ( . . . )

See 9.

1.1.7 Temporal.TimeZone ( . . . )

See 10.

1.1.8 Temporal.Duration ( . . . )

See 6.

1.2 Other Properties of the Temporal Object

1.2.1 Temporal.now

See 2.

2 The Temporal.now Object

The Temporal.now object:

  • is the intrinsic object %Temporal.now%.
  • is an ordinary object.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.
  • is not a function object.
  • does not have a [[Construct]] internal method; it cannot be used as a constructor with the new operator.
  • does not have a [[Call]] internal method; it cannot be invoked as a function.

2.1 Function Properties of the Temporal.now Object

2.1.1 Temporal.now.timeZone ( )

The following steps are taken:

  1. Return ? SystemTimeZone().

2.1.2 Temporal.now.absolute ( )

The following steps are taken:

  1. Return ? SystemAbsolute().

2.1.3 Temporal.now.dateTime ( [ temporalTimeZoneLike [ , calendar ] ] )

The dateTime method takes two arguments, temporalTimeZoneLike and calendar. The following steps are taken:

  1. Return ? SystemDateTime(temporalTimeZoneLike, calendar).

2.1.4 Temporal.now.date ( [ temporalTimeZoneLike [ , calendar ] ] )

The date method takes two arguments, temporalTimeZoneLike and calendar. The following steps are taken:

  1. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
  2. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]]).

2.1.5 Temporal.now.time ( [ temporalTimeZoneLike ] )

The time method takes one argument temporalTimeZoneLike. The following steps are taken:

  1. Let dateTime be ? SystemDateTime(temporalTimeZoneLike).
  2. Return ? CreateTemporalTime(dateTime.[[Hour]], dateTime.[[Minute]], dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]]).

2.2 Abstract operations

2.2.1 SystemTimeZone ( )

  1. Let identifier be ! DefaultTimeZone().
  2. Return ? CreateTimeZone(identifier).

2.2.2 SystemAbsolute ( )

  1. Let ns be the current UTC date and time, in nanoseconds since the epoch.
  2. Assert: ! ValidateAbsolute(ns) is true.
  3. Return ? CreateTemporalAbsolute(ns).

2.2.3 SystemDateTime ( [ temporalTimeZoneLike [ , calendarLike ] ] )

  1. If temporalTimeZoneLike is undefined, then
    1. Let timeZone be SystemTimeZone().
  2. Else,
    1. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  3. If calendarLike is undefined, then
    1. Let calendar be ! GetDefaultCalendar().
  4. Else,
    1. Let calendar be ? ToTemporalCalendar(calendarLike).
  5. Let absolute be ? SystemAbsolute().
  6. Return ? GetTemporalDateTimeFor(timeZone, absolute, calendar).

3 Temporal.Date Objects

A Temporal.Date object is an immutable Object that contains Number values corresponding to a particular year, month, and day.

3.1 The Temporal.Date Constructor

The Temporal.Date constructor:

  • is the intrinsic object %Temporal.Date%.
  • creates and initializes a new Temporal.Date object when called as a constructor.
  • is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.Date behaviour must include a super call to the %Temporal.Date% constructor to create and initialize subclass instances with the necessary internal slots.

3.1.1 Temporal.Date ( isoYear, isoMonth, isoDay )

When the Temporal.Date function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let y be ? ToInteger(isoYear).
  3. Let m be ? ToInteger(isoMonth).
  4. Let d be ? ToInteger(isoDay).
  5. Return ? CreateTemporalDate(y, m, d, NewTarget).

3.2 Properties of the Temporal.Date Constructor

The Temporal.Date constructor:

  • has a [[Prototype]] internal slot whose value is %FunctionPrototype%.
  • has the following properties:

3.2.1 Temporal.Date.prototype

The initial value of Temporal.Date.prototype is %Temporal.Date.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

3.2.2 get Temporal.Date [ @@species ]

Temporal.Date[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

3.2.3 Temporal.Date.from ( item [ , options ] )

The from method takes two arguments, item and options. The following steps are taken:

  1. Let overflow be ? ToTemporalOverflow(options).
  2. If Type(item) is Object, then
    1. Let result be ? ToTemporalDateRecord(item).
  3. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalDateString(string).
  4. Let constructor be the this value.
  5. Set result to ? RegulateDate(result.[[Year]], result.[[Month]], result.[[Day]], overflow).
  6. Return ? CreateTemporalDateFromStatic(constructor, result.[[Year]], result.[[Month]], result.[[Day]]).

3.2.4 Temporal.Date.compare ( one, two )

The compare method takes two arguments, one and two. The following steps are taken:

  1. Perform ? RequireInternalSlot(one, [[InitializedTemporalDate]]).
  2. Perform ? RequireInternalSlot(two, [[InitializedTemporalDate]]).
  3. Return ! CompareTemporalDate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]]).

3.3 Properties of the Temporal.Date Prototype Object

The Temporal.Date prototype object

  • is the intrinsic object %Temporal.Date.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.Date instance and does not have a [[InitializedTemporalDate]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

3.3.1 Temporal.Date.prototype.constructor

The initial value of Temporal.Date.prototype.constructor is %Temporal.Date%.

3.3.2 Temporal.Date.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.Date".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

3.3.3 get Temporal.Date.prototype.calendar

Temporal.Date.prototype.calendar is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Return temporalDate.[[Calendar]].

3.3.4 get Temporal.Date.prototype.year

Temporal.Date.prototype.year is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "year").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.5 get Temporal.Date.prototype.month

Temporal.Date.prototype.month is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "month").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.6 get Temporal.Date.prototype.day

Temporal.Date.prototype.day is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "day").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.7 get Temporal.Date.prototype.dayOfWeek

Temporal.Date.prototype.dayOfWeek is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "dayOfWeek").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.8 get Temporal.Date.prototype.dayOfYear

Temporal.Date.prototype.dayOfYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "dayOfYear").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.9 get Temporal.Date.prototype.weekOfYear

Temporal.Date.prototype.weekOfYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "weekOfYear").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.10 get Temporal.Date.prototype.daysInWeek

Temporal.Date.prototype.daysInWeek is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "daysInWeek").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.11 get Temporal.Date.prototype.daysInYear

Temporal.Date.prototype.daysInYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "daysInYear").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.12 get Temporal.Date.prototype.daysInMonth

Temporal.Date.prototype.daysInMonth is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "daysInMonth").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.13 get Temporal.Date.prototype.monthsInYear

Temporal.Date.prototype.monthsInYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "monthsInYear").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.14 get Temporal.Date.prototype.isLeapYear

Temporal.Date.prototype.isLeapYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let method be ? Get(calendar, "isLeapYear").
  5. Return ? Call(method, calendar, « temporalDate »).

3.3.15 Temporal.Date.prototype.toYearMonth ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Return ? CreateTemporalYearMonth(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]]).

3.3.16 Temporal.Date.prototype.toMonthDay ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Return ? CreateTemporalMonthDay(temporalDate.[[ISOMonth]], temporalDate.[[ISODay]]).

3.3.17 Temporal.Date.prototype.getFields ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Let record be ? ToPartialDate(temporalDate).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. For each row of Table 1, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. Let v be the value of record's field whose name is the Internal Slot value of the current row.
    3. Perform ! CreateDataPropertyOrThrow(fields, p, v).
  5. Return fields.

3.3.18 Temporal.Date.prototype.getISOFields ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", temporalDate.[[ISOYear]]).
  5. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", temporalDate.[[ISOMonth]]).
  6. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", temporalDate.[[ISODay]]).
  7. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalDate.[[Calendar]]).
  8. Return fields.

3.3.19 Temporal.Date.prototype.plus ( temporalDurationLike [ , options ] )

The plus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let balanceResult be ? BalanceDuration(duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "days").
  6. Let overflow be ? ToTemporalOverflow(options).
  7. Let result be ? AddDate(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], overflow).
  8. Assert: ! ValidateDate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  9. Return ? CreateTemporalDateFromInstance(temporalDate, result.[[Year]], result.[[Month]], result.[[Day]]).

3.3.20 Temporal.Date.prototype.minus ( temporalDurationLike [ , options ] )

The minus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let balanceResult be ? BalanceDuration(duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "days").
  6. Let overflow be ? ToTemporalOverflow(options).
  7. Let result be ? SubtractDate(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], overflow).
  8. Assert: ! ValidateDate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  9. Return ? CreateTemporalDateFromInstance(temporalDate, result.[[Year]], result.[[Month]], result.[[Day]]).

3.3.21 Temporal.Date.prototype.with ( temporalDateLike [ , options ] )

The with method takes two arguments, temporalDateLike and options. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let partialDate be ? ToPartialDate(temporalDateLike).
  4. Let overflow be ? ToTemporalOverflow(options).
  5. If partialDate.[[Year]] is not undefined, then
    1. Let y be partialDate.[[Year]].
  6. Else,
    1. Let y be temporalDate.[[ISOYear]].
  7. If partialDate.[[Month]] is not undefined, then
    1. Let m be partialDate.[[Month]].
  8. Else,
    1. Let m be temporalDate.[[ISOMonth]].
  9. If partialDate.[[Day]] is not undefined, then
    1. Let d be partialDate.[[Day]].
  10. Else,
    1. Let d be temporalDate.[[ISODay]].
  11. Let result be ? RegulateDate(y, m, d, overflow).
  12. Assert: ! ValidateDate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  13. Return ? CreateTemporalDateFromInstance(temporalDate, result.[[Year]], result.[[Month]], result.[[Day]]).

3.3.22 Temporal.Date.prototype.difference ( other [ , options ] )

The difference method takes two arguments, other and options. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalDate]]).
  4. Let largestUnit be ? ToLargestTemporalUnit(options, « "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds" », "days").
  5. Let result be ? DifferenceDate(other.[[ISOYear]], other.[[ISOMonth]], other.[[ISODay]], temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], largestUnit).
  6. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0).

3.3.23 Temporal.Date.prototype.equals ( other )

The equals method takes one argument other. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalDate]]).
  4. If temporalDate.[[Year]] ≠ other.[[Year]], return false.
  5. If temporalDate.[[Month]] ≠ other.[[Month]], return false.
  6. If temporalDate.[[Day]] ≠ other.[[Day]], return false.
  7. Return true.

3.3.24 Temporal.Date.prototype.toDateTime ( [ temporalTime ] )

The toDateTime method takes one optional argument temporalTime. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. If temporalTime is undefined, then
    1. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], 0, 0, 0, 0, 0, 0).
  4. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  5. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]]).

3.3.25 Temporal.Date.prototype.toString ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Return ! TemporalDateToString(temporalDate).

3.3.26 Temporal.Date.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. If the implementation does not include the ECMA-402 Internationalization API, then
    1. Return ! TemporalDateToString(temporalDate).
  4. Let dateFormat be ? Construct(%DateTimeFormat%, « locales, options »).
  5. Return ? FormatDateTime(dateFormat, temporalDate).

3.3.27 Temporal.Date.prototype.toJSON ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Return ! TemporalDateToString(temporalDate).

3.3.28 Temporal.Date.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

3.4 Properties of Temporal.Date Instances

Temporal.Date instances are ordinary objects that inherit properties from the %Temporal.Date.prototype%.

Temporal.Date instances have the following internal slots:

  • [[ISOYear]], representing the year. The value is an integer Number.
  • [[ISOMonth]], representing the month within the year. The value is an integer Number between 1 and 12, inclusive.
  • [[ISODay]], representing the day within the month. The value is an integer Number between 1 and DaysInMonth([[ISOYear]], [[ISOMonth]]), inclusive.
  • [[Calendar]], representing the calendar. The value is an Object.

3.5 Abstract Operations for Temporal.Date Objects

3.5.1 CreateTemporalDate ( isoYear, isoMonth, isoDay [ , newTarget ] )

  1. Perform ? RejectDate(isoYear, isoMonth, isoDay).
  2. If ! DateTimeWithinLimits(isoYear, isoMonth, isoDay, 12, 0, 0, 0, 0, 0) is not in range, then
    1. Throw a RangeError exception.
  3. If newTarget is not given, set it to %Temporal.Date%.
  4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Date.prototype%", « [[InitializedTemporalDate]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[Calendar]] »).
  5. Set object.[[ISOYear]] to isoYear.
  6. Set object.[[ISOMonth]] to isoMonth.
  7. Set object.[[ISODay]] to isoDay.
  8. TODO: Set it to the correct calendar. Set object.[[Calendar]] to ! GetDefaultCalendar().
  9. Return object.
Note

Deferring to DateTimeWithinLimits with an hour of 12 avoids trouble at the extremes of the representable range of dates, which stop just before midnight on each end.

3.5.2 CreateTemporalDateFromInstance ( temporalDate, isoYear, isoMonth, isoDay )

  1. Assert: Type(temporalDate) is Object and temporalDate has an [[InitializedTemporalDate]] internal slot.
  2. Assert: ! ValidateDate(isoYear, isoMonth, isoDay) is true.
  3. Let constructor be ? SpeciesConstructor(temporalDate, %Temporal.Date%).
  4. Let result be ? Construct(constructor, « isoYear, isoMonth, isoDay »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalDate]]).
  6. Return result.

3.5.3 CreateTemporalDateFromStatic ( constructor, year, month, day )

  1. Assert: ! ValidateDate(year, month, day) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « year, month, day »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalDate]]).
  5. Return result.

3.5.4 DifferenceDate ( y1, m1, d1, y2, m2, d2, largestUnit )

  1. Assert: largestUnit is one of "years", "months", "weeks", "days", "hours", "minutes", or "seconds".
  2. If largestUnit is not "years", "months", or "weeks", then
    1. Set largestUnit to "days".
  3. If ! CompareTemporalDate(y1, m1, d1, y2, m2, d2) < 0, then
    1. Let smaller be the new Record { [[Year]]: y1, [[Month]]: m1, [[Day]]: d1 }.
    2. Let greater be the new Record { [[Year]]: y2, [[Month]]: m2, [[Day]]: d2 }.
    3. Let sign be 1.
  4. Else,
    1. Let smaller be the new Record { [[Year]]: y2, [[Month]]: m2, [[Day]]: d2 }.
    2. Let greater be the new Record { [[Year]]: y1, [[Month]]: m1, [[Day]]: d1 }.
    3. Let sign be −1.
  5. Let years be greater.[[Year]] − smaller.[[Year]].
  6. If largestUnit is "days" or "weeks", then
    1. Let weeks be 0.
    2. Let days be ! ToDayOfYear(greater.[[Year]], greater.[[Month]], greater.[[Day]]) − ! ToDayOfYear(smaller.[[Year]], smaller.[[Month]], smaller.[[Day]]).
    3. Assert: years ≥ 0.
    4. Repeat, while years > 0,
      1. Set days to days + ! DaysInYear(smaller.[[Year]] + years − 1).
      2. Set years to years − 1.
    5. If largestUnit is "weeks", then
      1. Set weeks to floor(days / 7).
      2. Set days to days mod 7.
    6. Return the Record { [[Years]]: 0, [[Months]]: 0, [[Weeks]]: weeks × sign, [[Days]]: days × sign }.
  7. Let months be greater.[[Month]] − smaller.[[Month]].
  8. Let balanceResult be ? BalanceDurationDate(years, months, smaller.[[Year]], smaller.[[Month]], smaller.[[Day]]).
  9. Set years to balanceResult.[[Years]].
  10. Set months to balanceResult.[[Months]].
  11. Let days be ! ToDayOfYear(greater.[[Year]], greater.[[Month]], greater.[[Day]]) − ! ToDayOfYear(balanceResult.[[Year]], balanceResult.[[Month]], smaller.[[Day]]).
  12. If days < 0, then
    1. Set months to months − 1.
    2. Set balanceResult to ? BalanceDurationDate(years, months, smaller.[[Year]], smaller.[[Month]], smaller.[[Day]]).
    3. Set years to balanceResult.[[Years]].
    4. Set months to balanceResult.[[Months]].
    5. Set days to ! ToDayOfYear(greater.[[Year]], greater.[[Month]], greater.[[Day]]) − ! ToDayOfYear(balanceResult.[[Year]], balanceResult.[[Month]], smaller.[[Day]]).
    6. If greater.[[Year]] > balanceResult.[[Year]], then
      1. Set days to days + ! DaysInYear(balanceResult.[[Year]]).
  13. If largestUnit is "months", then
    1. Set months to years × 12.
    2. Set years to 0.
  14. Return the Record { [[Years]]: years × sign, [[Months]]: months × sign, [[Weeks]]: 0, [[Days]]: days × sign }.

3.5.5 ToTemporalDateRecord ( temporalDateLike )

  1. Assert: Type(temporalDateLike) is Object.
  2. If temporalDateLike has an [[InitializedTemporalDate]] internal slot, then
    1. Return the Record { [[Year]]: temporalDateLike.[[Year]], [[Month]]: temporalDateLike.[[Month]], [[Day]]: temporalDateLike.[[Day]], }.
  3. Let result be a new Record with all the internal slots given in the Internal Slot column in Table 1.
  4. For each row of Table 1, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalDateLike, property).
    3. If value is undefined, then
      1. Throw a TypeError exception.
    4. Let value be ? ToInteger(value).
    5. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. Return result.

3.5.6 ToPartialDate ( temporalDateLike )

  1. If Type(temporalDateLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let result be { [[Year]]: undefined, [[Month]]: undefined, [[Day]]: undefined }.
  3. Let any be false.
  4. For each row of Table 1, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalDateLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToInteger(value).
      3. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. If any is false, then
    1. Throw a TypeError exception.
  6. Return result.
Table 1: Properties of a TemporalDateLike
Internal Slot Property
[[Day]] "day"
[[Month]] "month"
[[Year]] "year"

3.5.7 RegulateDate ( year, month, day, overflow )

  1. Assert: overflow is either "constrain" or "reject".
  2. If overflow is "reject", then
    1. Perform ? RejectDate(year, month, day).
    2. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
  3. If overflow is "constrain", then
    1. Return ! ConstrainDate(year, month, day).

3.5.8 ValidateDate ( year, month, day )

  1. Assert: year, month, and day are integer Number values.
  2. If month < 1 or month > 12, then
    1. Return false.
  3. Let daysInMonth be ? DaysInMonth(year, month).
  4. If day < 1 or day < daysInMonth, then
    1. Return false.
  5. Return true.

3.5.9 RejectDate ( year, month, day )

  1. Assert: year, month, and day are integer Number values.
  2. If ! ValidateDate(year, month, day) is false, then
    1. Throw a RangeError exception.

3.5.10 ConstrainDate ( year, month, day )

  1. Assert: year, month, and day are integer Number values.
  2. Set month to ! ConstrainToRange(month, 1, 12).
  3. Set day to ! ConstrainToRange(day, 1, ! DaysInMonth(year, month)).
  4. Return the Record { [[Year]]: yearMonth.[[Year]], [[Month]]: yearMonth.[[Month]], [[Day]]: day }.

3.5.11 BalanceDate ( year, month, day )

  1. If day is +∞ or −∞, then
    1. Throw a RangeError exception.
  2. Let balancedYearMonth be ? BalanceYearMonth(year, month).
  3. Let month be balancedYearMonth.[[Month]].
  4. Let year be balancedYearMonth.[[Year]].
  5. NOTE: To deal with negative numbers of days whose absolute value is greater than the number of days in a year, the following section subtracts years and adds days until the number of days is greater than −366 or −365.
  6. Let daysInYear be 0.
  7. If month > 2, then
    1. Let testYear be year.
  8. Else,
    1. Let testYear be year − 1.
  9. Repeat, while day < −1 × ! DaysInYear(testYear),
    1. Set day to day + ! DaysInYear(testYear).
    2. Set year to year − 1.
    3. Set testYear to testYear − 1.
  10. NOTE: To deal with numbers of days greater than the number of days in a year, the following section adds years and subtracts days until the number of days is less than 366 or 365.
  11. Let testYear be year + 1.
  12. Repeat, while day > ! DaysInYear(testYear),
    1. Set day to day − ! DaysInYear(testYear).
    2. Set year to year + 1.
    3. Set testYear to testYear + 1.
  13. NOTE: To deal with negative numbers of days whose absolute value greater than the number of days in the current month, the following section subtracts months and adds days until the number of days is greater than 0.
  14. Repeat, while day < 1,
    1. Set balancedYearMonth be ? BalanceYearMonth(year, month − 1).
    2. Set year to balancedYearMonth.[[Year]].
    3. Set month to balancedYearMonth.[[Month]].
    4. Set day to day + ! DaysInMonth(year, month).
  15. NOTE: To deal with numbers of days greater than the number of days in the current month, the following section adds months and subtracts days until the number of days is less than the number of days in the month.
  16. Repeat, while day > ! DaysInMonth(year, month),
    1. Set day to day − ! DaysInMonth(year, month).
    2. Set balancedYearMonth be ? BalanceYearMonth(year, month + 1).
    3. Set year to balancedYearMonth.[[Year]].
    4. Set month to balancedYearMonth.[[Month]].
  17. Return the new Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.

3.5.12 BalanceDurationDate ( years, months, startYear, startMonth, startDay )

  1. If months < 0, then
    1. Set years to years − 1.
    2. Set months to months + 12.
  2. Let balanceResult be ? BalanceYearMonth(startYear + years, startMonth + months).
  3. Repeat, while startDay > ! DaysInMonth(balanceResult.[[Year]], balanceResult.[[Month]]),
    1. Set months to months − 1.
    2. If months < 0, then
      1. Set years to years − 1.
      2. Set months to months + 12.
    3. Set balanceResult to ? BalanceYearMonth(startYear + years, startMonth + months).
  4. Return the new Record { [[Year]]: balanceResult.[[Year]], [[Month]]: balanceResult.[[Month]], [[Years]]: years, [[Months]]: months }.

3.5.13 PadYear ( y )

  1. Assert: y is an integer Number value.
  2. If y > 999 and y ≤ 9999, then
    1. Return y formatted as a four-digit decimal number.
  3. If y ≥ 0, let yearSign be "+"; otherwise, let yearSign be "-".
  4. Let year be abs(y), formatted as a six-digit decimal number, padded to the left with zeroes as necessary.
  5. Return the string-concatenation of yearSign and year.

3.5.14 TemporalDateToString ( temporalDate )

  1. Assert: Type(temporalDate) is Object.
  2. Assert: temporalDate has an [[InitializedTemporalDate]] internal slot.
  3. Let year be ! PadYear(temporalDate.[[ISOYear]]).
  4. Let month be temporalDate.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Let day be temporalDate.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  6. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), and day.

3.5.15 AddDate ( year, month, day, years, months, weeks, days, overflow )

  1. Assert: year, month, day, years, months, weeks, and days are integer Number values.
  2. Assert: overflow is either "constrain" or "reject".
  3. Let y be year + years.
  4. Let m be month + months.
  5. Let intermediate be ? BalanceYearMonth(y, m).
  6. Let intermediate be ? RegulateDate(intermediate.[[Year]], intermediate.[[Month]], day, overflow).
  7. Set days to days + 7 × weeks.
  8. Let d be intermediate.[[Day]] + days.
  9. Let intermediate be ? BalanceDate(intermediate.[[Year]], intermediate.[[Month]], d).
  10. Return ? RegulateDate(intermediate.[[Year]], intermediate.[[Month]], intermediate.[[Day]], overflow).

3.5.16 SubtractDate ( year, month, day, years, months, days, overflow )

  1. Assert: year, month, day, years, months, and days are integer Number values.
  2. Assert: overflow is either "constrain" or "reject".
  3. Set days to days + 7 × weeks.
  4. Let intermediate be ? BalanceDate(year, month, day - days).
  5. Let d be intermediate.[[Day]].
  6. Let intermediate be ? BalanceYearMonth(intermediate.[[Year]] - years, intermediate.[[Month]] - months).
  7. Return ? RegulateDate(intermediate.[[Year]], intermediate.[[Month]], d, overflow).

3.5.17 CompareTemporalDate ( y1, m1, d1, y2, m2, d2 )

  1. If y1 > y2, return 1.
  2. If y1 < y2, return -1.
  3. If m1 > m2, return 1.
  4. If m1 < m2, return -1.
  5. If d1 > d2, return 1.
  6. If d1 < d2, return -1.
  7. Return +0.

4 Temporal.Time Objects

A Temporal.Time object is an immutable Object that contains Number values corresponding to a particular hour, minute, second, millisecond, microsecond, and nanosecond.

4.1 The Temporal.Time Constructor

The Temporal.Time constructor is the %Temporal.Time% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.Time object.

The Temporal.Time constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Time behaviour must include a super call to the %Temporal.Time% constructor to create and initialize subclass instances with the necessary internal slots.

4.1.1 Temporal.Time ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] )

When the Temporal.Time function is called, the following steps are taken:

Note
The value of ? ToInteger(undefined) is 0.
  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let hour be ? ToInteger(hour).
  3. Let minute be ? ToInteger(minute).
  4. Let second be ? ToInteger(second).
  5. Let millisecond be ? ToInteger(millisecond).
  6. Let microsecond be ? ToInteger(microsecond).
  7. Let nanosecond be ? ToInteger(nanosecond).
  8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget).

4.2 Properties of the Temporal.Time Constructor

The value of the [[Prototype]] internal slot of the Temporal.Time constructor is the intrinsic object %FunctionPrototype%.

The Temporal.Time constructor has the following properties:

4.2.1 Temporal.Time.prototype

The initial value of Temporal.Time.prototype is %Temporal.Time.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

4.2.2 get Temporal.Time [ @@species ]

Temporal.Time[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

4.2.3 Temporal.Time.from ( item [ , options ] )

The from method takes two arguments, item and options. The following steps are taken:

  1. Let overflow be ? ToTemporalOverflow(options).
  2. If Type(item) is Object, then
    1. Let result be ? ToTemporalTimeRecord(item).
  3. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalTimeString(string).
  4. Let constructor be the this value.
  5. Set result to ? RegulateTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], overflow).
  6. Return ? CreateTemporalTimeFromStatic(constructor, result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.2.4 Temporal.Time.compare ( one, two )

The compare method takes two arguments, one and two. The following steps are taken:

  1. Perform ? RequireInternalSlot(one, [[InitializedTemporalTime]]).
  2. Perform ? RequireInternalSlot(two, [[InitializedTemporalTime]]).
  3. Return ! CompareTemporalTime(one.[[Hour]], one.[[Minute]], one.[[Second]], one.[[Millisecond]], one.[[Microsecond]], one.[[Nanosecond]], two.[[Hour]], two.[[Minute]], two.[[Second]], two.[[Millisecond]], two.[[Microsecond]], two.[[Nanosecond]]).

4.3 Properties of the Temporal.Time Prototype Object

The Temporal.Time prototype object

  • is the intrinsic object %Temporal.Time.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.Time instance and does not have a [[InitializedTemporalTime]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

4.3.1 Temporal.Time.prototype.constructor

The initial value of Temporal.Time.prototype.constructor is %Temporal.Time%.

4.3.2 Temporal.Date.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.Time".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

4.3.3 get Temporal.Time.prototype.hour

Temporal.Time.prototype.hour is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return temporalTime.[[Hour]].

4.3.4 get Temporal.Time.prototype.minute

Temporal.Time.prototype.minute is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return temporalTime.[[Minute]].

4.3.5 get Temporal.Time.prototype.second

Temporal.Time.prototype.second is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return temporalTime.[[Second]].

4.3.6 get Temporal.Time.prototype.millisecond

Temporal.Time.prototype.millisecond is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return temporalTime.[[Millisecond]].

4.3.7 get Temporal.Time.prototype.microsecond

Temporal.Time.prototype.microsecond is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return temporalTime.[[Microsecond]].

4.3.8 get Temporal.Time.prototype.nanosecond

Temporal.Time.prototype.nanosecond is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return temporalTime.[[Nanosecond]].

4.3.9 Temporal.Time.prototype.plus ( temporalDurationLike [ , options ] )

The plus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Perform ? ToTemporalOverflow(options).
  6. Let sign be ! DurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  7. If sign < 0, then
    1. Let result be ? SubtractTime(temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]]).
  8. Else,
    1. Let result be ? AddTime(temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  9. Return ? CreateTemporalTimeFromInstance(temporalTime, result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.10 Temporal.Time.prototype.minus ( temporalDurationLike [ , options ] )

The minus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Perform ? ToTemporalOverflow(options).
  6. Let sign be ! DurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  7. If sign < 0, then
    1. Let result be ? AddTime(temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]]).
  8. Else,
    1. Let result be ? SubtractTime(temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  9. Return ? CreateTemporalTimeFromInstance(temporalTime, result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.11 Temporal.Time.prototype.with ( temporalTimeLike [ , options ] )

The with method takes two arguments, temporalTimeLike and options. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Let partialTime be ? ToPartialTime(temporalTimeLike).
  4. Let overflow be ? ToTemporalOverflow(options).
  5. If partialTime.[[Hour]] is not undefined, then
    1. Let hour be partialTime.[[Hour]].
  6. Else,
    1. Let hour be temporalTime.[[Hour]].
  7. If partialTime.[[Minute]] is not undefined, then
    1. Let minute be partialTime.[[Minute]].
  8. Else,
    1. Let minute be temporalTime.[[Minute]].
  9. If partialTime.[[Second]] is not undefined, then
    1. Let second be partialTime.[[Second]].
  10. Else,
    1. Let second be temporalTime.[[Second]].
  11. If partialTime.[[Millisecond]] is not undefined, then
    1. Let millisecond be partialTime.[[Millisecond]].
  12. Else,
    1. Let millisecond be temporalTime.[[Millisecond]].
  13. If partialTime.[[Microsecond]] is not undefined, then
    1. Let microsecond be partialTime.[[Microsecond]].
  14. Else,
    1. Let microsecond be temporalTime.[[Microsecond]].
  15. If partialTime.[[Nanosecond]] is not undefined, then
    1. Let nanosecond be partialTime.[[Nanosecond]].
  16. Else,
    1. Let nanosecond be temporalTime.[[Nanosecond]].
  17. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow).
  18. Return ? CreateTemporalTimeFromInstance(temporalTime, result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.12 Temporal.Time.prototype.difference ( other [ , options ] )

The difference method takes two arguments, other and options. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalTime]]).
  4. Let smallestUnit be ? ToSmallestTemporalDurationUnit(options, « "years", "months", "weeks", "days" », "nanoseconds").
  5. Let largestUnit be ? ToLargestTemporalUnit(options, « "years", "months", "weeks", "days" », "hours").
  6. Perform ? ValidateTemporalDifferenceUnits(largestUnit, smallestUnit).
  7. Let roundingMode be ? ToTemporalRoundingMode(options).
  8. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  9. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  10. Let result be ! DifferenceTime(other.[[Hour]], other.[[Minute]], other.[[Second]], other.[[Millisecond]], other.[[Microsecond]], other.[[Nanosecond]], temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]]).
  11. Set result to ? RoundDuration(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode).
  12. Set result to ! BalanceDuration(0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], largestUnit).
  13. Return ? CreateTemporalDuration(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

4.3.13 Temporal.Time.prototype.round ( options )

The round method takes one argument, options. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. If options is undefined, then
    1. Throw a TypeError exception.
  4. Let smallestUnit be ? ToSmallestTemporalUnit(options, « "day" »).
  5. Let roundingMode be ? ToTemporalRoundingMode(options).
  6. If smallestUnit is "hour", then
    1. Let maximum be 24.
  7. Else if smallestUnit is "minute" or "second", then
    1. Let maximum be 60.
  8. Else,
    1. Let maximum be 1000.
  9. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  10. Let result be ? RoundTime(temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]], roundingIncrement, smallestUnit, roundingMode).
  11. Return ? CreateTemporalTimeFromInstance(temporalTime, result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.14 Temporal.Time.prototype.equals ( other )

The equals method takes one argument other. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalTime]]).
  4. If temporalTime.[[Hour]] ≠ other.[[Hour]], return false.
  5. If temporalTime.[[Minute]] ≠ other.[[Minute]], return false.
  6. If temporalTime.[[Second]] ≠ other.[[Second]], return false.
  7. If temporalTime.[[Millisecond]] ≠ other.[[Millisecond]], return false.
  8. If temporalTime.[[Microsecond]] ≠ other.[[Microsecond]], return false.
  9. If temporalTime.[[Nanosecond]] ≠ other.[[Nanosecond]], return false.
  10. Return true.

4.3.15 Temporal.Time.prototype.toDateTime ( temporalDate )

The toDateTime method takes one argument temporalDate. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  4. Return ? CreateTemporalDateTime(temporalDate.[[Year]], temporalDate.[[Month]], temporalDate.[[Day]], temporalTime.[[Hour]], temporalTime.[[Minute]], temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]]).

4.3.16 Temporal.Time.prototype.getFields ( )

The following steps are taken:

  1. Let temporalTime be the this value.
  2. Let record be ? ToPartialTime(temporalTime).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. For each row of Table 2, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. Let v be the value of record's field whose name is the Internal Slot value of the current row.
    3. Perform ! CreateDataPropertyOrThrow(fields, p, v).
  5. Return fields.

4.3.17 Temporal.Time.prototype.toString ( )

The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return ! TemporalTimeToString(temporalTime).

4.3.18 Temporal.Time.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. If the implementation does not include the ECMA-402 Internationalization API, then
    1. Return ! TemporalTimeToString(temporalTime).
  4. Let dateFormat be ? Construct(%DateTimeFormat%, « locales, options »).
  5. Return ? FormatDateTime(dateFormat, temporalTime).

4.3.19 Temporal.Time.prototype.toJSON ( )

The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return ! TemporalTimeToString(temporalTime).

4.3.20 Temporal.Time.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

4.4 Abstract operations

4.4.1 DifferenceTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2 )

  1. Let hours be h2h1.
  2. Let minutes be min2min1.
  3. Let seconds be s2s1.
  4. Let milliseconds be ms2ms1.
  5. Let microseconds be mus2mus1.
  6. Let nanoseconds be ns2ns1.
  7. Let sign be ! DurationSign(0, 0, 0, 0, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  8. Let bt be ? BalanceTime(hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  9. Return the new Record { [[Days]]: bt.[[Days]] × sign, [[Hours]]: bt.[[Hour]] × sign, [[Minutes]]: bt.[[Minute]] × sign, [[Seconds]]: bt.[[Second]] × sign, [[Milliseconds]]: bt.[[Millisecond]] × sign, [[Microseconds]]: bt.[[Microsecond]] × sign, [[Nanoseconds]]: bt.[[Nanosecond]] × sign }.

4.4.2 ToPartialTime ( temporalTimeLike )

  1. If Type(temporalTimeLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let result be the new Record { [[Hour]]: undefined, [[Minute]]: undefined, [[Second]]: undefined, [[Millisecond]]: undefined, [[Microsecond]]: undefined, [[Nanosecond]]: undefined }.
  3. Let any be false.
  4. For each row of Table 2, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalTimeLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToInteger(value).
      3. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. If any is false, then
    1. Throw a TypeError exception.
  6. Return result.
Table 2: Properties of a TemporalTimeLike
Internal Slot Property
[[Hour]] "hour"
[[Microsecond]] "microsecond"
[[Millisecond]] "millisecond"
[[Minute]] "minute"
[[Nanosecond]] "nanosecond"
[[Second]] "second"

4.4.3 RegulateTime ( hour, minute, second, millisecond, microsecond, nanosecond, overflow )

  1. Assert: overflow is either "constrain" or "reject".
  2. If overflow is "constrain", then
    1. Return ! ConstrainTime(hour, minute, second, millisecond, microsecond, nanosecond).
  3. If overflow is "reject", then
    1. If ! ValidateTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, then
      1. Throw a RangeError exception.
    2. Return the new Record { [[Days]]: 0, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.

4.4.4 ValidateTime ( hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: hour, minute, second, millisecond, microsecond, and nanosecond are integer Number values.
  2. If hour < 0 or hour > 23, then
    1. Return false.
  3. If minute < 0 or minute > 59, then
    1. Return false.
  4. If second < 0 or second > 59, then
    1. Return false.
  5. If millisecond < 0 or millisecond > 999, then
    1. Return false.
  6. If microsecond < 0 or microsecond > 999, then
    1. Return false.
  7. If nanosecond < 0 or nanosecond > 999, then
    1. Return false.
  8. Return true.

4.4.5 BalanceTime ( hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: hour, minute, second, millisecond, microsecond, and nanosecond are integer Number values.
  2. If hour is +∞ or −∞, or minute is +∞ or −∞, or second is +∞ or −∞, or millisecond is +∞ or −∞, or microsecond is +∞ or −∞, or nanosecond is +∞ or −∞, then
    1. Throw a RangeError exception.
  3. Set microsecond to microsecond + floor(nanosecond / 1000).
  4. Set nanosecond to ! NonNegativeModulo(nanosecond, 1000).
  5. Set millisecond to millisecond + floor(microsecond / 1000).
  6. Set microsecond to ! NonNegativeModulo(microsecond, 1000).
  7. Set second to second + floor(millisecond / 1000).
  8. Set millisecond to ! NonNegativeModulo(millisecond, 1000).
  9. Set minute to minute + floor(second / 60).
  10. Set second to ! NonNegativeModulo(second, 60).
  11. Set hour to hour + floor(minute / 60).
  12. Set minute to ! NonNegativeModulo(minute, 60).
  13. Let days be floor(hour / 24).
  14. Set hour to ! NonNegativeModulo(hour, 24).
  15. Return the new Record { [[Days]]: days, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.

4.4.6 ConstrainTime ( hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: hour, minute, second, millisecond, microsecond, and nanosecond are integer Number values.
  2. Set hour to ! ConstrainToRange(hour, 0, 23).
  3. Set minute to ! ConstrainToRange(minute, 0, 59).
  4. Set second to ! ConstrainToRange(second, 0, 59).
  5. Set millisecond to ! ConstrainToRange(millisecond, 0, 999).
  6. Set microsecond to ! ConstrainToRange(microsecond, 0, 999).
  7. Set nanosecond to ! ConstrainToRange(nanosecond, 0, 999).
  8. Return the Record { [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.

4.4.7 CreateTemporalTime ( hour, minute, second, millisecond, microsecond, nanosecond [ , newTarget ] )

  1. If ! ValidateTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, then
    1. Throw a RangeError exception.
  2. If newTarget is not given, set it to %Temporal.Time%.
  3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Time.prototype%", « [[InitializedTemporalTime]], [[Hour]], [[Minute]], [[Second]], [[Millisecond]], [[Microsecond]], [[Nanosecond]] »).
  4. Set object.[[Hour]] to hour.
  5. Set object.[[Minute]] to minute.
  6. Set object.[[Second]] to second.
  7. Set object.[[Millisecond]] to millisecond.
  8. Set object.[[Microsecond]] to microsecond.
  9. Set object.[[Nanosecond]] to nanosecond.
  10. Return object.

4.4.8 CreateTemporalTimeFromInstance ( temporalTime, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: Type(temporalTime) is Object and temporalTime has an [[InitializedTemporalTime]] internal slot.
  2. Assert: ! ValidateTime(hour, minute, second, millisecond, microsecond, nanosecond) is true.
  3. Let constructor be ? SpeciesConstructor(temporalTime, %Temporal.Time%).
  4. Let result be ? Construct(constructor, « hour, minute, second, millisecond, microsecond, nanosecond »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalTime]]).
  6. Return result.

4.4.9 CreateTemporalTimeFromStatic ( constructor, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: ! ValidateTime(hour, minute, second, millisecond, microsecond, nanosecond) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « hour, minute, second, millisecond, microsecond, nanosecond »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalTime]]).
  5. Return result.

4.4.10 ToTemporalTimeRecord ( temporalTimeLike )

Note
The value of ? ToInteger(undefined) is 0.
  1. Assert: Type(temporalTimeLike) is Object.
  2. If temporalTimeLike has an [[InitializedTemporalTime]] internal slot, then
    1. Return the Record { [[Hour]]: temporalTimeLike.[[Hour]], [[Minute]]: temporalTimeLike.[[Minute]], [[Second]]: temporalTimeLike.[[Second]], [[Millisecond]]: temporalTimeLike.[[Millisecond]], [[Microsecond]]: temporalTimeLike.[[Microsecond]], [[Nanosecond]]: temporalTimeLike.[[Nanosecond]] }.
  3. Let result be a new Record with all the internal slots given in the Internal Slot column in Table 2.
  4. For each row of Table 2, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalTimeLike, property).
    3. Let value be ? ToInteger(value).
    4. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. Return result.

4.4.11 TemporalTimeToString ( temporalTime )

  1. Assert: Type(temporalTime) is Object.
  2. Assert: temporalTime has an [[InitializedTemporalTime]] internal slot.
  3. Let hour be temporalTime.[[Hour]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  4. Let minute be temporalTime.[[Minute]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Let seconds be ! FormatSecondsStringPart(temporalTime.[[Second]], temporalTime.[[Millisecond]], temporalTime.[[Microsecond]], temporalTime.[[Nanosecond]]).
  6. Return the string-concatenation of hour, the code unit 0x003A (COLON), minute, and seconds.

4.4.12 CompareTemporalTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2 )

  1. If h1 > h2, return 1.
  2. If h1 < h2, return -1.
  3. If min1 > min2, return 1.
  4. If min1 < min2, return -1.
  5. If s1 > s2, return 1.
  6. If s1 < s2, return -1.
  7. If ms1 > ms2, return 1.
  8. If ms1 < ms2, return -1.
  9. If mus1 > mus2, return 1.
  10. If mus1 < mus2, return -1.
  11. If ns1 > ns2, return 1.
  12. If ns1 < ns2, return -1.
  13. Return +0.

4.4.13 AddTime ( hour, minute, second, millisecond, microsecond, nanosecond, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. Assert: hour, minute, second, millisecond, microsecond, nanosecond, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds are integer Number values.
  2. Let hour be hour + hours.
  3. Let minute be minute + minutes.
  4. Let second be second + seconds.
  5. Let millisecond be millisecond + milliseconds.
  6. Let microsecond be microsecond + microseconds.
  7. Let nanosecond be nanosecond + nanoseconds.
  8. Return ? BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond).

4.4.14 SubtractTime ( hour, minute, second, millisecond, microsecond, nanosecond, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. Assert: hour, minute, second, millisecond, microsecond, nanosecond, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds are integer Number values.
  2. Set hour to hourhours.
  3. Set minute to minuteminutes.
  4. Set second to secondseconds.
  5. Set millisecond to millisecondmilliseconds.
  6. Set microsecond to microsecondmicroseconds.
  7. Set nanosecond to nanosecondnanoseconds.
  8. Return ? BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond).

4.4.15 RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, roundingMode )

  1. Let hour, minute, second, millisecond, microsecond, nanosecond, and increment each be the mathematical values of themselves.
  2. Let fractionalSecond be nanosecond × 10−9 + microsecond × 10−6 + millisecond × 10−3 + second.
  3. If unit is "day", then
    1. Let quantity be ((fractionalSecond ÷ 60 + minute) ÷ 60 + hour) ÷ 24.
  4. Else if unit is "hour", then
    1. Let quantity be (fractionalSecond ÷ 60 + minute) ÷ 60 + hour.
  5. Else if unit is "minute", then
    1. Let quantity be fractionalSecond ÷ 60 + minute.
  6. Else if unit is "second", then
    1. Let quantity be fractionalSecond.
  7. Else if unit is "millisecond", then
    1. Let quantity be nanosecond × 10−6 + microsecond × 10−3 + millisecond.
  8. Else if unit is "microsecond", then
    1. Let quantity be nanosecond × 10−3 + microsecond.
  9. Else,
    1. Assert: unit is "nanosecond".
    2. Let quantity be nanosecond.
  10. Let result be ! RoundNumberToIncrement(quantity, increment, roundingMode).
  11. If unit is "day", then
    1. Return the new Record { [[Days]]: result, [[Hour]]: 0, [[Minute]]: 0, [[Second]]: 0, [[Millisecond]]: 0, [[Microsecond]]: 0, [[Nanosecond]]: 0 }.
  12. If unit is "hour", then
    1. Return ? BalanceTime(result, 0, 0, 0, 0, 0).
  13. If unit is "minute", then
    1. Return ? BalanceTime(hour, result, 0, 0, 0, 0).
  14. If unit is "second", then
    1. Return ? BalanceTime(hour, minute, result, 0, 0, 0).
  15. If unit is "millisecond", then
    1. Return ? BalanceTime(hour, minute, second, result, 0, 0).
  16. If unit is "microsecond", then
    1. Return ? BalanceTime(hour, minute, second, millisecond, result, 0).
  17. Assert: unit is "nanosecond".
  18. Return ? BalanceTime(hour, minute, second, millisecond, microsecond, result).

5 Temporal.DateTime Objects

A Temporal.DateTime object is an immutable Object that contains Number values corresponding to a particular year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond.

5.1 The Temporal.DateTime Constructor

The Temporal.DateTime constructor is the %Temporal.DateTime% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.DateTime object.

The Temporal.DateTime constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified DateTime behaviour must include a super call to the %Temporal.DateTime% constructor to create and initialize subclass instances with the necessary internal slots.

5.1.1 Temporal.DateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] )

When the Temporal.DateTime function is called, the following steps are taken:

Note
The value of ? ToInteger(undefined) is 0.
  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let isoYear be ? ToInteger(isoYear).
  3. Let isoMonth be ? ToInteger(isoMonth).
  4. Let isoDay be ? ToInteger(isoDay).
  5. Let hour be ? ToInteger(hour).
  6. Let minute be ? ToInteger(minute).
  7. Let second be ? ToInteger(second).
  8. Let millisecond be ? ToInteger(millisecond).
  9. Let microsecond be ? ToInteger(microsecond).
  10. Let nanosecond be ? ToInteger(nanosecond).
  11. If calendarLike is undefined, then
    1. Let calendar be ! GetDefaultCalendar().
  12. Else,
    1. Let calendar be ? ToTemporalCalendar(calendarLike).
  13. TODO: pass calendar along.
  14. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, NewTarget).

5.2 Properties of the Temporal.DateTime Constructor

The value of the [[Prototype]] internal slot of the Temporal.DateTime constructor is the intrinsic object %FunctionPrototype%.

The Temporal.DateTime constructor has the following properties:

5.2.1 Temporal.DateTime.prototype

The initial value of Temporal.DateTime.prototype is %Temporal.DateTime.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

5.2.2 get Temporal.DateTime [ @@species ]

Temporal.DateTime[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

5.2.3 Temporal.DateTime.from ( item [ , options ] )

The from method takes two arguments, item and options. The following steps are taken:

  1. Let overflow be ? ToTemporalOverflow(options).
  2. If Type(item) is Object, then
    1. Let result be ? ToTemporalDateTimeRecord(item).
  3. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalDateTimeString(string).
  4. Let constructor be the this value.
  5. Set result to ? RegulateDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], overflow).
  6. Return ? CreateTemporalDateTimeFromStatic(constructor, result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

5.2.4 Temporal.DateTime.compare ( one, two )

The compare method takes two arguments, one and two. The following steps are taken:

  1. Perform ? RequireInternalSlot(one, [[InitializedTemporalDateTime]]).
  2. Perform ? RequireInternalSlot(two, [[InitializedTemporalDateTime]]).
  3. Return ! CompareTemporalDateTime(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], one.[[Hour]], one.[[Minute]], one.[[Second]], one.[[Millisecond]], one.[[Microsecond]], one.[[Nanosecond]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], two.[[Hour]], two.[[Minute]], two.[[Second]], two.[[Millisecond]], two.[[Microsecond]], two.[[Nanosecond]]).

5.3 Properties of the Temporal.DateTime Prototype Object

The Temporal.DateTime prototype object

  • is the intrinsic object %Temporal.DateTime.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.DateTime instance and does not have a [[InitializedTemporalDateTime]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

5.3.1 Temporal.DateTime.prototype.constructor

The initial value of Temporal.DateTime.prototype.constructor is %Temporal.DateTime%.

5.3.2 Temporal.DateTime.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.DateTime".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

5.3.3 get Temporal.DateTime.prototype.calendar

Temporal.DateTime.prototype.calendar is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Calendar]].

5.3.4 get Temporal.DateTime.prototype.year

Temporal.DateTime.prototype.year is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "year").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.5 get Temporal.DateTime.prototype.month

Temporal.DateTime.prototype.month is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "month").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.6 get Temporal.DateTime.prototype.day

Temporal.DateTime.prototype.day is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "day").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.7 get Temporal.DateTime.prototype.hour

Temporal.DateTime.prototype.hour is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Hour]].

5.3.8 get Temporal.DateTime.prototype.minute

Temporal.DateTime.prototype.minute is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Minute]].

5.3.9 get Temporal.DateTime.prototype.second

Temporal.DateTime.prototype.second is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Second]].

5.3.10 get Temporal.DateTime.prototype.millisecond

Temporal.DateTime.prototype.millisecond is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Millisecond]].

5.3.11 get Temporal.DateTime.prototype.microsecond

Temporal.DateTime.prototype.microsecond is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Microsecond]].

5.3.12 get Temporal.DateTime.prototype.nanosecond

Temporal.DateTime.prototype.nanosecond is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return dateTime.[[Nanosecond]].

5.3.13 get Temporal.DateTime.prototype.dayOfWeek

Temporal.DateTime.prototype.dayOfWeek is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "dayOfWeek").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.14 get Temporal.DateTime.prototype.dayOfYear

Temporal.DateTime.prototype.dayOfYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "dayOfYear").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.15 get Temporal.DateTime.prototype.weekOfYear

Temporal.DateTime.prototype.weekOfYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "weekOfYear").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.16 get Temporal.DateTime.prototype.daysInWeek

Temporal.DateTime.prototype.daysInWeek is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "daysInWeek").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.17 get Temporal.DateTime.prototype.daysInYear

Temporal.DateTime.prototype.daysInYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "daysInYear").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.18 get Temporal.DateTime.prototype.daysInMonth

Temporal.DateTime.prototype.daysInMonth is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "daysInMonth").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.19 get Temporal.DateTime.prototype.monthsInYear

Temporal.DateTime.prototype.monthsInYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "monthsInYear").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.20 get Temporal.DateTime.prototype.isLeapYear

Temporal.DateTime.prototype.isLeapYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let method be ? Get(calendar, "isLeapYear").
  5. Return ? Call(method, calendar, « dateTime »).

5.3.21 Temporal.DateTime.prototype.with ( temporalDateTimeLike [ , options ] )

The with method takes two arguments, temporalDateTimeLike and options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let partialDateTime be ? ToPartialDateTime(temporalDateTimeLike).
  4. Let overflow be ? ToTemporalOverflow(options).
  5. If partialDateTime.[[Year]] is not undefined, then
    1. Let year be partialDateTime.[[Year]].
  6. Else,
    1. Let year be dateTime.[[ISOYear]].
  7. If partialDateTime.[[Month]] is not undefined, then
    1. Let month be partialDateTime.[[Month]].
  8. Else,
    1. Let month be dateTime.[[ISOMonth]].
  9. If partialDateTime.[[Day]] is not undefined, then
    1. Let day be partialDateTime.[[Day]].
  10. Else,
    1. Let day be dateTime.[[ISODay]].
  11. If partialDateTime.[[Hour]] is not undefined, then
    1. Let hour be partialDateTime.[[Hour]].
  12. Else,
    1. Let hour be dateTime.[[Hour]].
  13. If partialDateTime.[[Minute]] is not undefined, then
    1. Let minute be partialDateTime.[[Minute]].
  14. Else,
    1. Let minute be dateTime.[[Minute]].
  15. If partialDateTime.[[Second]] is not undefined, then
    1. Let second be partialDateTime.[[Second]].
  16. Else,
    1. Let second be dateTime.[[Second]].
  17. If partialDateTime.[[Millisecond]] is not undefined, then
    1. Let millisecond be partialDateTime.[[Millisecond]].
  18. Else,
    1. Let millisecond be dateTime.[[Millisecond]].
  19. If partialDateTime.[[Microsecond]] is not undefined, then
    1. Let microsecond be partialDateTime.[[Microsecond]].
  20. Else,
    1. Let microsecond be dateTime.[[Microsecond]].
  21. If partialDateTime.[[Nanosecond]] is not undefined, then
    1. Let nanosecond be partialDateTime.[[Nanosecond]].
  22. Else,
    1. Let nanosecond be dateTime.[[Nanosecond]].
  23. Let result be ? RegulateDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, overflow).
  24. Assert: ! ValidateDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  25. Return ? CreateTemporalDateTimeFromInstance(dateTime, result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

5.3.22 Temporal.DateTime.prototype.plus ( temporalDurationLike [ , options ] )

The plus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let overflow be ? ToTemporalOverflow(options).
  6. Let timePart be ? AddTime(dateTime.[[Hour]], dateTime.[[Minute]], dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  7. Let datePart be ? AddDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow).
  8. Let datePart be ? BalanceDate(datePart.[[Year]], datePart.[[Month]], datePart.[[Day]] + timePart.[[Day]]).
  9. Let result be ? RegulateDateTime(datePart.[[Year]], datePart.[[Month]], datePart.[[Day]], timePart.[[Hour]], timePart.[[Minute]], timePart.[[Second]], timePart.[[Millisecond]], timePart.[[Microsecond]], timePart.[[Nanosecond]], overflow).
  10. Assert: ! ValidateDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  11. Return ? CreateTemporalDateTimeFromInstance(dateTime, result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

5.3.23 Temporal.DateTime.prototype.minus ( temporalDurationLike [ , options ] )

The minus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let overflow be ? ToTemporalOverflow(options).
  6. Let timePart be ? SubtractTime(dateTime.[[Hour]], dateTime.[[Minute]], dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  7. Let datePart be ? SubtractDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]] - timePart.[[Day]], overflow).
  8. Let result be ? RegulateDateTime(datePart.[[Year]], datePart.[[Month]], datePart.[[Day]], timePart.[[Hour]], timePart.[[Minute]], timePart.[[Second]], timePart.[[Millisecond]], timePart.[[Microsecond]], timePart.[[Nanosecond]], overflow).
  9. Assert: ! ValidateDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  10. Return ? CreateTemporalDateTimeFromInstance(dateTime, result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

5.3.24 Temporal.DateTime.prototype.difference ( other [ , options ] )

The difference method takes two arguments, other and options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalDateTime]]).
  4. Let smallestUnit be ? ToSmallestTemporalDurationUnit(options, « », "nanoseconds").
  5. If smallestUnit is "years", "months", or "weeks", then
    1. Let defaultLargestUnit be smallestUnit.
  6. Else,
    1. Let defaultLargestUnit be "days".
  7. Let largestUnit be ? ToLargestTemporalUnit(options, « », defaultLargestUnit).
  8. Perform ? ValidateTemporalDifferenceUnits(largestUnit, smallestUnit).
  9. Let roundingMode be ? ToTemporalRoundingMode(options).
  10. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  11. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  12. Let timeDifference be ! DifferenceTime(other.[[Hour]], other.[[Minute]], other.[[Second]], other.[[Millisecond]], other.[[Microsecond]], other.[[Nanosecond]], dateTime.[[Hour]], dateTime.[[Minute]], dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]]).
  13. Let balanceResult be ? BalanceDate(greater.[[ISOYear]], greater.[[ISOMonth]], greater.[[ISODay]] + timeDifference.[[Days]]).
  14. Let dateDifference be ! DifferenceDate(smaller.[[ISOYear]], smaller.[[ISOMonth]], smaller.[[ISODay]], balanceResult.[[Year]], balanceResult.[[Month]], balanceResult.[[Day]], largestUnit).
  15. Let roundResult be ? RoundDuration(dateDifference.[[Years]], dateDifference.[[Months]], dateDifference.[[Weeks]], dateDifference.[[Days]], timeDifference.[[Hours]], timeDifference.[[Minutes]], timeDifference.[[Seconds]], timeDifference.[[Milliseconds]], timeDifference.[[Microseconds]], timeDifference.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, dateTime).
  16. Let result be ! BalanceDuration(roundResult.[[Days]], roundResult.[[Hours]], roundResult.[[Minutes]], roundResult.[[Seconds]], roundResult.[[Milliseconds]], roundResult.[[Microseconds]], roundResult.[[Nanoseconds]], largestUnit).
  17. Return ? CreateTemporalDuration(roundResult.[[Years]], roundResult.[[Months]], roundResult.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

5.3.25 Temporal.DateTime.prototype.round ( options )

The round method takes one argument, options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. If options is undefined, then
    1. Throw a TypeError exception.
  4. Let smallestUnit be ? ToSmallestTemporalUnit(options, « »).
  5. Let roundingMode be ? ToTemporalRoundingMode(options).
  6. If smallestUnit is "day", then
    1. Let maximum be 1.
  7. Else if smallestUnit is "hour", then
    1. Let maximum be 24.
  8. Else if smallestUnit is "minute" or "second", then
    1. Let maximum be 60.
  9. Else,
    1. Let maximum be 1000.
  10. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  11. Let result be ? RoundTime(dateTime.[[Hour]], dateTime.[[Minute]], dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]], roundingIncrement, smallestUnit, roundingMode).
  12. Let balanceResult be ? BalanceDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]] + result.[[Days]]).
  13. Return ? CreateTemporalDateTimeFromInstance(dateTime, balanceResult.[[Year]], balanceResult.[[Month]], balanceResult.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

5.3.26 Temporal.DateTime.prototype.equals ( other )

The equals method takes one argument other. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalDateTime]]).
  4. If dateTime.[[Year]] ≠ other.[[Year]], return false.
  5. If dateTime.[[Month]] ≠ other.[[Month]], return false.
  6. If dateTime.[[Day]] ≠ other.[[Day]], return false.
  7. If dateTime.[[Hour]] ≠ other.[[Hour]], return false.
  8. If dateTime.[[Minute]] ≠ other.[[Minute]], return false.
  9. If dateTime.[[Second]] ≠ other.[[Second]], return false.
  10. If dateTime.[[Millisecond]] ≠ other.[[Millisecond]], return false.
  11. If dateTime.[[Microsecond]] ≠ other.[[Microsecond]], return false.
  12. If dateTime.[[Nanosecond]] ≠ other.[[Nanosecond]], return false.
  13. Return true.

5.3.27 Temporal.DateTime.prototype.toString ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ! TemporalDateTimeToString(dateTime).

5.3.28 Temporal.DateTime.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. If the implementation does not include the ECMA-402 Internationalization API, then
    1. Return ! TemporalDateTimeToString(dateTime).
  4. Let dateFormat be ? Construct(%DateTimeFormat%, « locales, options »).
  5. Return ? FormatDateTime(dateFormat, dateTime).

5.3.29 Temporal.DateTime.prototype.toJSON ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ! TemporalDateTimeToString(dateTime).

5.3.30 Temporal.DateTime.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

5.3.31 Temporal.DateTime.prototype.toAbsolute ( temporalTimeZoneLike [ , options ] )

The toAbsolute method takes two arguments, temporalTimeZoneLike and options. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  4. Let disambiguation be ? ToTemporalDisambiguation(options).
  5. Return ? GetTemporalAbsoluteFor(timeZone, dateTime, disambiguation).

5.3.32 Temporal.DateTime.prototype.toDate ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]]).

5.3.33 Temporal.DateTime.prototype.toYearMonth ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ? CreateTemporalYearMonth(dateTime.[[ISOYear]], dateTime.[[ISOMonth]]).

5.3.34 Temporal.DateTime.prototype.toMonthDay ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ? CreateTemporalMonthDay(dateTime.[[ISOMonth]], dateTime.[[ISODay]]).

5.3.35 Temporal.DateTime.prototype.toTime ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ? CreateTemporalTime(dateTime.[[Hour]], dateTime.[[Minute]], dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]]).

5.3.36 Temporal.DateTime.prototype.getFields ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Let record be ? ToPartialDateTime(dateTime).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. For each row of Table 3, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. Let v be the value of record's field whose name is the Internal Slot value of the current row.
    3. Perform ! CreateDataPropertyOrThrow(fields, p, v).
  5. Return fields.

5.3.37 Temporal.DateTime.prototype.getISOFields ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", dateTime.[[ISOYear]]).
  5. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", dateTime.[[ISOMonth]]).
  6. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", dateTime.[[ISODay]]).
  7. Perform ! CreateDataPropertyOrThrow(fields, "hour", dateTime.[[Hour]]).
  8. Perform ! CreateDataPropertyOrThrow(fields, "minute", dateTime.[[Minute]]).
  9. Perform ! CreateDataPropertyOrThrow(fields, "second", dateTime.[[Second]]).
  10. Perform ! CreateDataPropertyOrThrow(fields, "millisecond", dateTime.[[Millisecond]]).
  11. Perform ! CreateDataPropertyOrThrow(fields, "microsecond", dateTime.[[Microsecond]]).
  12. Perform ! CreateDataPropertyOrThrow(fields, "nanosecond", dateTime.[[Nanosecond]]).
  13. Perform ! CreateDataPropertyOrThrow(fields, "calendar", dateTime.[[Calendar]]).
  14. Return fields.

5.4 Abstract operations

5.4.1 GetEpochFromParts ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integer Number values.
  2. Assert: month ≥ 1 and month ≤ 12.
  3. Assert: day ≥ 1 and day ≤ ! DaysInMonth(year, month).
  4. Assert: ! ValidateTime(hour, minute, second, millisecond, microsecond, nanosecond) is true.
  5. Let date be ! MakeDay(year, month, day).
  6. Let time be ! MakeTime(hour, minute, second, millisecond).
  7. Let ms be ! MakeDate(date, time).
  8. Assert: ms is finite.
  9. Return ms × 1,000,000 + microsecond × 1,000 + nanosecond.

5.4.2 DateTimeWithinLimits ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

Note

Temporal.DateTime objects can represent points in time within 24 hours (8.64 × 1016 nanoseconds) of the Temporal.Absolute boundaries This ensures that a Temporal.Absolute object can be converted into a Temporal.DateTime object using any time zone.

  1. Let ns be ! GetEpochFromParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond).
  2. If ns ≤ -8.64 × 1021 - 8.64 × 1016, then
    1. Return too early.
  3. If ns ≥ 8.64 × 1021 + 8.64 × 1016, then
    1. Return too late.
  4. Return in range.

5.4.3 ToPartialDateTime ( temporalDateTimeLike )

  1. If Type(temporalDateTimeLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let result be the new Record { [[Year]]: undefined, [[Month]]: undefined, [[Day]]: undefined, [[Hour]]: undefined, [[Minute]]: undefined, [[Second]]: undefined, [[Millisecond]]: undefined, [[Microsecond]]: undefined, [[Nanosecond]]: undefined }.
  3. Let any be false.
  4. For each row of Table 3, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalDateTimeLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToInteger(value).
      3. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. If any is false, then
    1. Throw a TypeError exception.
  6. Return result.
Table 3: Internal slots and properties for Temporal.DateTime argument objects
Internal Slot Property Optional
[[Day]] "day" false
[[Hour]] "hour" true
[[Microsecond]] "microsecond" true
[[Millisecond]] "millisecond" true
[[Minute]] "minute" true
[[Month]] "month" false
[[Nanosecond]] "nanosecond" true
[[Second]] "second" true
[[Year]] "year" false

5.4.4 RegulateDateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, overflow )

  1. Assert: overflow is one of "constrain" or "reject".
  2. If overflow is "constrain", then
    1. Return ! ConstrainDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond).
  3. If overflow is "reject", then
    1. If ! ValidateDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond) is false, then
      1. Throw a RangeError exception.
    2. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.

5.4.5 ValidateDateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integer Number values.
  2. If month < 1 or month > 12, then
    1. Return false.
  3. Let maxDay be ! DaysInMonth(year, month).
  4. If day < 1 or day > maxDay, then
    1. Return false.
  5. If ! ValidateTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, then
    1. Return false.
  6. Return true.

5.4.6 ConstrainDateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: year, month, and day are integer Number values.
  2. Set month to ! ConstrainToRange(month, 1, 12).
  3. Set day to ! ConstrainToRange(day, 1, ! DaysInMonth(year, month)).
  4. Let constrainedTime be ! ConstrainTime(hour, minute, second, millisecond, microsecond, nanosecond).
  5. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day, [[Hour]]: constrainedTime.[[Hour]], [[Minute]]: constrainedTime.[[Minute]], [[Second]]: constrainedTime.[[Second]], [[Millisecond]]: constrainedTime.[[Millisecond]], [[Microsecond]]: constrainedTime.[[Microsecond]], [[Nanosecond]]: constrainedTime.[[Nanosecond]] }.

5.4.7 BalanceDateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Let balancedTime be ? BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond).
  2. Let balancedDate be ? BalanceDate(year, month, day + balancedTime.[[Days]]).
  3. Return the Record { [[Year]]: balancedDate.[[Year]], [[Month]]: balancedDate.[[Month]], [[Day]]: balancedDate.[[Day]], [[Hour]]: balancedTime.[[Hour]], [[Minute]]: balancedTime.[[Minute]], [[Second]]: balancedTime.[[Second]], [[Millisecond]]: balancedTime.[[Millisecond]], [[Microsecond]]: balancedTime.[[Microsecond]], [[Nanosecond]]: balancedTime.[[Nanosecond]] }.

5.4.8 CreateTemporalDateTime ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond [ , newTarget ] )

  1. If ! ValidateDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond) is false, then
    1. Throw a RangeError exception.
  2. If ! DateTimeWithinLimits(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond) is not in range, then
    1. Throw a RangeError exception.
  3. If newTarget is not given, set it to %Temporal.DateTime%.
  4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.DateTime.prototype%", « [[InitializedTemporalDateTime]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[Hour]], [[Minute]], [[Second]], [[Millisecond]], [[Microsecond]], [[Nanosecond]], [[Calendar]] »).
  5. Set object.[[ISOYear]] to isoYear.
  6. Set object.[[ISOMonth]] to isoMonth.
  7. Set object.[[ISODay]] to isoDay.
  8. Set object.[[Hour]] to hour.
  9. Set object.[[Minute]] to minute.
  10. Set object.[[Second]] to second.
  11. Set object.[[Millisecond]] to millisecond.
  12. Set object.[[Microsecond]] to microsecond.
  13. Set object.[[Nanosecond]] to nanosecond.
  14. TODO: Set it to the correct calendar. Set object.[[Calendar]] to ! GetDefaultCalendar().
  15. Return object.

5.4.9 CreateTemporalDateTimeFromInstance ( dateTime, isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: Type(dateTime) is Object and dateTime has an [[InitializedTemporalDateTime]] internal slot.
  2. Assert: ! ValidateDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond) is true.
  3. Let constructor be ? SpeciesConstructor(dateTime, %Temporal.DateTime%).
  4. Let result be ? Construct(constructor, « isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalDateTime]]).
  6. Return result.

5.4.10 CreateTemporalDateTimeFromStatic ( constructor, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: ! ValidateDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « year, month, day, hour, minute, second, millisecond, microsecond, nanosecond »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalDateTime]]).
  5. Return result.

5.4.11 ToTemporalDateTimeRecord ( temporalDateTimeLike )

Note
The value of ? ToInteger(undefined) is 0.
  1. Assert: Type(temporalDateTimeLike) is Object.
  2. If temporalDateTimeLike has an [[InitializedTemporalDateTime]] internal slot, then
    1. Return the Record { [[Year]]: temporalDateTimeLike.[[Year]], [[Month]]: temporalDateTimeLike.[[Month]], [[Day]]: temporalDateTimeLike.[[Day]], [[Hour]]: temporalDateTimeLike.[[Hour]], [[Minute]]: temporalDateTimeLike.[[Minute]], [[Second]]: temporalDateTimeLike.[[Second]], [[Millisecond]]: temporalDateTimeLike.[[Millisecond]], [[Microsecond]]: temporalDateTimeLike.[[Microsecond]], [[Nanosecond]]: temporalDateTimeLike.[[Nanosecond]] }.
  3. Let result be a new Record with all the internal slots given in the Internal Slot column in Table 3.
  4. For each row of Table 3, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalDateTimeLike, property).
    3. If value is undefined and the Optional value of the current row is false, then
      1. Throw a TypeError exception.
    4. Let value be ? ToInteger(value).
    5. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. Return result.

5.4.12 TemporalDateTimeToString ( dateTime )

  1. Assert: Type(dateTime) is Object.
  2. Assert: dateTime has an [[InitializedTemporalDateTime]] internal slot.
  3. Let year be ! PadYear(dateTime.[[ISOYear]]).
  4. Let month be dateTime.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Let day be dateTime.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  6. Let hour be dateTime.[[Hour]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  7. Let minute be dateTime.[[Minute]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  8. Let seconds be ! FormatSecondsStringPart(dateTime.[[Second]], dateTime.[[Millisecond]], dateTime.[[Microsecond]], dateTime.[[Nanosecond]]).
  9. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, 0x0054 (LATIN CAPITAL LETTER T), hour, the code unit 0x003A (COLON), minute, and seconds.

5.4.13 CompareTemporalDateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, ns2 )

  1. If y1 > y2, return 1.
  2. If y1 < y2, return -1.
  3. If mon1 > mon2, return 1.
  4. If mon1 < mon2, return -1.
  5. If d1 > d2, return 1.
  6. If d1 < d2, return -1.
  7. If h1 > h2, return 1.
  8. If h1 < h2, return -1.
  9. If min1 > min2, return 1.
  10. If min1 < min2, return -1.
  11. If s1 > s2, return 1.
  12. If s1 < s2, return -1.
  13. If ms1 > ms2, return 1.
  14. If ms1 < ms2, return -1.
  15. If mus1 > mus2, return 1.
  16. If mus1 < mus2, return -1.
  17. If ns1 > ns2, return 1.
  18. If ns1 < ns2, return -1.
  19. Return +0.

6 Temporal.Duration Objects

A Temporal.Duration object describes the difference between two like Date, Time, or DateTime objects. Objects of this type are only created via the .difference() methods of these objects.

6.1 The Temporal.Duration Constructor

The Temporal.Duration constructor is the %Temporal.Duration% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.Duration object.

The Temporal.Duration constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Duration behaviour must include a super call to the %Temporal.Duration% constructor to create and initialize subclass instances with the necessary internal slots.

6.1.1 Temporal.Duration ( [ years [ , months [ , weeks [ , days [ , hours [ , minutes [ , seconds [ , milliseconds [ , microseconds [ , nanoseconds ] ] ] ] ] ] ] ] ] ] )

When the Temporal.Duration function is called, the following steps are taken:

Note
The value of ? ToInteger(undefined) is 0.
  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let y be ? ToInteger(years).
  3. Let mo be ? ToInteger(months).
  4. Let w be ? ToInteger(weeks).
  5. Let d be ? ToInteger(days).
  6. Let h be ? ToInteger(hours).
  7. Let m be ? ToInteger(minutes).
  8. Let s be ? ToInteger(seconds).
  9. Let ms be ? ToInteger(milliseconds).
  10. Let mis be ? ToInteger(microseconds).
  11. Let ns be ? ToInteger(nanoseconds).
  12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).

6.2 Properties of the Temporal.Duration Constructor

The value of the [[Prototype]] internal slot of the Temporal.Duration constructor is the intrinsic object %FunctionPrototype%.

The Temporal.Duration constructor has the following properties:

6.2.1 Temporal.Duration.prototype

The initial value of Temporal.Duration.prototype is %Temporal.Duration.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

6.2.2 get Temporal.Duration [ @@species ]

Temporal.Duration[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

6.2.3 Temporal.Duration.from ( item [ , options ] )

The from method takes two arguments, item and options. The following steps are taken:

  1. Let overflow be ? ToTemporalDurationOverflow(options).
  2. If Type(item) is Object, then
    1. Let result be ? ToTemporalDurationRecord(arg).
  3. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalDurationString(string).
  4. Let constructor be the this value.
  5. Set result to ? RegulateDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], overflow).
  6. Return ? CreateTemporalDurationFromStatic(constructor, result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

6.3 Properties of the Temporal.Duration Prototype Object

The Temporal.Duration prototype object

  • is the intrinsic object %Temporal.Duration.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.Duration instance and doesn't have an [[InitializedTemporalDuration]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

6.3.1 Temporal.Duration.prototype.constructor

The initial value of Temporal.Duration.prototype.constructor is %Temporal.Duration%.

6.3.2 Temporal.Date.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.Duration".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

6.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:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Years]].

6.3.4 get Temporal.Duration.prototype.months

Temporal.Duration.prototype.months is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Months]].

6.3.5 get Temporal.Duration.prototype.weeks

Temporal.Duration.prototype.weeks is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Weeks]].

6.3.6 get Temporal.Duration.prototype.days

Temporal.Duration.prototype.days is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Days]].

6.3.7 get Temporal.Duration.prototype.hours

Temporal.Duration.prototype.hours is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Hours]].

6.3.8 get Temporal.Duration.prototype.minutes

Temporal.Duration.prototype.minutes is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Minutes]].

6.3.9 get Temporal.Duration.prototype.seconds

Temporal.Duration.prototype.seconds is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Seconds]].

6.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:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Milliseconds]].

6.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:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Microseconds]].

6.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:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return duration.[[Nanoseconds]].

6.3.13 get Temporal.Duration.prototype.sign

Temporal.Duration.prototype.sign is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return ! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).

6.3.14 Temporal.Duration.prototype.with ( temporalDurationLike [ , options ] )

The with method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Let temporalDurationLike be ? ToPartialDuration(temporalDurationLike).
  4. Let overflow be ? ToTemporalDurationOverflow(options).
  5. If temporalDurationLike.[[Years]] is not undefined, then
    1. Let years be temporalDurationLike.[[Years]].
  6. Else,
    1. Let year be duration.[[Year]].
  7. If temporalDurationLike.[[Months]] is not undefined, then
    1. Let months be temporalDurationLike.[[Months]].
  8. Else,
    1. Let months be duration.[[Months]].
  9. If temporalDurationLike.[[Weeks]] is not undefined, then
    1. Let weeks be temporalDurationLike.[[Weeks]].
  10. Else,
    1. Let weeks be duration.[[Weeks]].
  11. If temporalDurationLike.[[Days]] is not undefined, then
    1. Let days be temporalDurationLike.[[Days]].
  12. Else,
    1. Let days be duration.[[Days]].
  13. If temporalDurationLike.[[Hours]] is not undefined, then
    1. Let hours be temporalDurationLike.[[Hours]].
  14. Else,
    1. Let hours be duration.[[Hours]].
  15. If temporalDurationLike.[[Minutes]] is not undefined, then
    1. Let minutes be temporalDurationLike.[[Minutes]].
  16. Else,
    1. Let minutes be duration.[[Minutes]].
  17. If temporalDurationLike.[[Seconds]] is not undefined, then
    1. Let seconds be temporalDurationLike.[[Seconds]].
  18. Else,
    1. Let seconds be duration.[[Seconds]].
  19. If temporalDurationLike.[[Milliseconds]] is not undefined, then
    1. Let milliseconds be temporalDurationLike.[[Milliseconds]].
  20. Else,
    1. Let milliseconds be duration.[[Milliseconds]].
  21. If temporalDurationLike.[[Microseconds]] is not undefined, then
    1. Let microseconds be temporalDurationLike.[[Microseconds]].
  22. Else,
    1. Let microseconds be duration.[[Microseconds]].
  23. If temporalDurationLike.[[Nanoseconds]] is not undefined, then
    1. Let nanoseconds be temporalDurationLike.[[Nanoseconds]].
  24. Else,
    1. Let nanoseconds be duration.[[Nanoseconds]].
  25. Let result be ? RegulateDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, overflow).
  26. Return ? CreateTemporalDurationFromInstance(duration, result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

6.3.15 Temporal.Duration.prototype.negated ( )

The negated method takes no arguments. It performs the following steps when called:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return ? CreateTemporalDurationFromInstance(duration, −duration.[[Years]], −duration.[[Months]], −duration.[[Weeks]], −duration.[[Days]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]]).

6.3.16 Temporal.Duration.prototype.abs ( )

The abs method takes no arguments. It performs the following steps when called:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return ? CreateTemporalDurationFromInstance(duration, abs(duration.[[Years]]), abs(duration.[[Months]]), abs(duration.[[Weeks]]), abs(duration.[[Days]]), abs(duration.[[Hours]]), abs(duration.[[Minutes]]), abs(duration.[[Seconds]]), abs(duration.[[Milliseconds]]), abs(duration.[[Microseconds]]), abs(duration.[[Nanoseconds]])).

6.3.17 Temporal.Duration.prototype.plus ( other [ , options ] )

The plus method takes two arguments, other and options. The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Set other to ? ToLimitedTemporalDuration(other, « »).
  4. Perform ? RejectDurationSign (other.[[Years]], other.[[Months]], other.[[Weeks]], other.[[Days]], other.[[Hours]], other.[[Minutes]], other.[[Seconds]], other.[[Milliseconds]], other.[[Microseconds]], other.[[Nanoseconds]]).
  5. Let overflow be ? ToTemporalDurationOverflow(options).
  6. Let result be ? DurationArithmetic(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], other.[[Years]], other.[[Months]], other.[[Weeks]], other.[[Days]], other.[[Hours]], other.[[Minutes]], other.[[Seconds]], other.[[Milliseconds]], other.[[Microseconds]], other.[[Nanoseconds]], overflow).
  7. Return ? CreateTemporalDurationFromInstance(duration, result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

6.3.18 Temporal.Duration.prototype.minus ( other [ , options ] )

The minus method takes two arguments, other and options. The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Set other to ? ToLimitedTemporalDuration(other, « »).
  4. Perform ? RejectDurationSign (other.[[Years]], other.[[Months]], other.[[Weeks]], other.[[Days]], other.[[Hours]], other.[[Minutes]], other.[[Seconds]], other.[[Milliseconds]], other.[[Microseconds]], other.[[Nanoseconds]]).
  5. Let overflow be ? ToTemporalDurationOverflow(options).
  6. Let result be ? DurationArithmetic(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], −other.[[Years]], −other.[[Months]], −other.[[Weeks]], −other.[[Days]], −other.[[Hours]], −other.[[Minutes]], −other.[[Seconds]], −other.[[Milliseconds]], −other.[[Microseconds]], −other.[[Nanoseconds]], overflow).
  7. Return ? CreateTemporalDurationFromInstance(duration, result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

6.3.19 Temporal.Duration.prototype.getFields ( )

The following steps are taken:

  1. Let duration be the this value.
  2. Let record be ? ToPartialDuration(duration).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. For each row of Table 4, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. Let v be the value of record's field whose name is the Internal Slot value of the current row.
    3. Perform ! CreateDataPropertyOrThrow(fields, p, v).
  5. Return fields.

6.3.20 Temporal.Duration.prototype.toString ( )

The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return ? TemporalDurationToString(duration).

6.3.21 Temporal.Duration.prototype.toJSON ( )

The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return ? TemporalDurationToString(duration).

6.3.22 Temporal.Duration.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. TODO.

6.3.23 Temporal.Duration.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

6.4 Abstract Operations

6.4.1 ToTemporalDurationRecord ( temporalDurationLike )

Note
The value of ? ToInteger(undefined) is 0.
  1. Assert: Type(temporalDurationLike) is Object.
  2. If temporalDurationLike has an [[InitializedTemporalDuration]] internal slot, then
    1. Return the Record { [[Years]]: temporalDurationLike.[[Years]], [[Months]]: temporalDurationLike.[[Months]], [[Weeks]]: temporalDurationLike.[[Weeks]], [[Days]]: temporalDurationLike.[[Days]], [[Hours]]: temporalDurationLike.[[Hours]], [[Minutes]]: temporalDurationLike.[[Minutes]], [[Seconds]]: temporalDurationLike.[[Seconds]], [[Milliseconds]]: temporalDurationLike.[[Milliseconds]], [[Microseconds]]: temporalDurationLike.[[Microseconds]], [[Nanoseconds]]: temporalDurationLike.[[Nanoseconds]] }.
  3. Let result be a new Record with all the internal slots given in the Internal Slot column in Table 4.
  4. For each row of Table 4, except the header row, in table order, do
    1. Let prop be the Property value of the current row.
    2. Let val be ? Get(temporalDurationLike, prop).
    3. Let val be ? ToInteger(val).
    4. Set result's internal slot whose name is the Internal Slot value of the current row to val.
  5. Return result.

6.4.2 DurationSign ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. For each value v of years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, do
    1. If v < 0, return −1.
    2. If v > 0, return 1.
  2. Return 0.

6.4.3 RejectDurationSign ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. Let sign be ! DurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  2. For each value v of years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, do
    1. If v < 0 and sign > 0, throw a RangeError exception.
    2. If v > 0 and sign < 0, throw a RangeError exception.
  3. Return true.

6.4.4 ValidateTemporalDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. Let sign be ! DurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  2. For each value v of years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, do
    1. If v is infinite, return false.
    2. If v < 0 and sign > 0, return false.
    3. If v > 0 and sign < 0, return false.
  3. Return true.

6.4.5 ToPartialDuration ( temporalDurationLike )

  1. If Type(temporalDurationLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let result be the new Record { [[Years]]: undefined, [[Months]]: undefined, [[Weeks]]: undefined, [[Days]]: undefined, [[Hours]]: undefined, [[Minutes]]: undefined, [[Seconds]]: undefined, [[Milliseconds]]: undefined, [[Microseconds]]: undefined, [[Nanoseconds]]: undefined }.
  3. Let any be false.
  4. For each row of Table 4, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalDurationLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToInteger(value).
      3. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. If any is false, then
    1. Throw a TypeError exception.
  6. Return result.

6.4.6 CreateTemporalDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , newTarget ] )

  1. If ! ValidateTemporalDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, then
    1. Throw a RangeError exception.
  2. If newTarget is not given, set it to %Temporal.Duration%.
  3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Duration.prototype%", « [[InitializedTemporalDuration]], [[Years]], [[Months]], [[Weeks]], [[Days]], [[Hours]], [[Minutes]], [[Seconds]], [[Milliseconds]], [[Microseconds]], [[Nanoseconds]] »).
  4. Set object.[[Years]] to years.
  5. Set object.[[Months]] to months.
  6. Set object.[[Weeks]] to weeks.
  7. Set object.[[Days]] to days.
  8. Set object.[[Hours]] to hours.
  9. Set object.[[Minutes]] to minutes.
  10. Set object.[[Seconds]] to seconds.
  11. Set object.[[Milliseconds]] to milliseconds.
  12. Set object.[[Microseconds]] to microseconds.
  13. Set object.[[Nanoseconds]] to nanoseconds.
  14. Return object.

6.4.7 CreateTemporalDurationFromInstance ( duration, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. Assert: Type(duration) is Object and duration has an [[InitializedTemporalDuration]] internal slot.
  2. Assert: ! ValidateDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is true.
  3. Let constructor be ? SpeciesConstructor(duration, %Temporal.Duration%).
  4. Let result be ? Construct(constructor, « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalDuration]]).
  6. Return result.

6.4.8 CreateTemporalDurationFromStatic ( constructor, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

  1. Assert: ! ValidateDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalDuration]]).
  5. Return result.

6.4.9 BalanceDuration ( days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, largestUnit )

  1. Assert: largestUnit is one of "days", "hours", "minutes", or "seconds".
  2. Let sign be ! DurationSign(0, 0, 0, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  3. Let bt be ? BalanceTime(abs(hours), abs(minutes), abs(seconds), abs(milliseconds), abs(microseconds), abs(nanoseconds)).
  4. Increment days by bt.[[Days]].
  5. Set hours to bt.[[Hour]].
  6. Set minutes to bt.[[Minute]].
  7. Set seconds to bt.[[Second]].
  8. Set milliseconds to bt.[[Millisecond]].
  9. Set microseconds to bt.[[Microsecond]].
  10. Set nanoseconds to bt.[[Nanosecond]].
  11. If largestUnit is "hours", "minutes", "seconds", "milliseconds", "microseconds", or "nanoseconds", then
    1. Increment hours by 24 × days.
    2. Set days to 0.
  12. If largestUnit is "minutes", "seconds", "milliseconds", "microseconds", or "nanoseconds", then
    1. Increment minutes by 60 × hours.
    2. Set hours to 0.
  13. If largestUnit is "seconds", "milliseconds", "microseconds", or "nanoseconds", then
    1. Increment seconds by 60 × minutes.
    2. Set minutes to 0.
  14. If largestUnit is "milliseconds", "microseconds", or "nanoseconds", then
    1. Increment milliseconds by 1000 × seconds.
    2. Set seconds to 0.
  15. If largestUnit is "microseconds" or "nanoseconds", then
    1. Increment microseconds by 1000 × milliseconds.
    2. Set milliseconds to 0.
  16. If largestUnit is "nanoseconds", then
    1. Increment nanoseconds by 1000 × microseconds.
    2. Set microseconds to 0.
  17. Return the new Record { [[Days]]: days × sign, [[Hours]]: hours × sign, [[Minutes]]: minutes × sign, [[Seconds]]: seconds × sign, [[Milliseconds]]: milliseconds × sign, [[Microseconds]]: microseconds × sign, [[Nanoseconds]]: nanoseconds × sign }.

6.4.10 RegulateDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, overflow )

  1. Assert: overflow is either "constrain" or "balance".
  2. If ! ValidateTemporalDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, then
    1. Throw a RangeError exception.
  3. If overflow is "balance", then
    1. Let bd be ! BalanceDuration(days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, "days").
    2. Set days to bd.[[Days]].
    3. Set hours to bd.[[Hours]].
    4. Set minutes to bd.[[Minutes]].
    5. Set seconds to bd.[[Seconds]].
    6. Set milliseconds to bd.[[Milliseconds]].
    7. Set microseconds to bd.[[Microseconds]].
    8. Set nanoseconds to bd.[[Nanoseconds]].
    9. If ! ValidateTemporalDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, then
      1. Throw a RangeError exception.
  4. Return the new Record { [[Years]]: years, [[Months]]: months, [[Weeks]]: weeks, [[Days]]: days, [[Hours]]: hours, [[Minutes]]: minutes, [[Seconds]]: seconds, [[Milliseconds]]: milliseconds, [[Microseconds]]: microseconds, [[Nanoseconds]]: nanoseconds }.

6.4.11 DurationArithmetic ( y1, mon1, w1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, w2, d2, h2, min2, s2, ms2, mus2, ns2, overflow )

  1. Assert: y1, mon1, w1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, w2, d2, h2, min2, s2, ms2, mus2, ns2 are integer Number values.
  2. Assert: overflow is either "balance" or "constrain".
  3. Let nanoseconds be ns1 + ns2.
  4. Let microseconds be mus1 + mus2.
  5. Let milliseconds be ms1 + ms2.
  6. Let seconds be s1 + s2.
  7. Let minutes be min1 + min2.
  8. Let hours be h1 + h2.
  9. Let days be d1 + d2.
  10. Let weeks be w1 + w2.
  11. Let months be mon1 + mon2.
  12. Let years be y1 + y2.
  13. Let sign be ! DurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  14. Set years to years × sign.
  15. Set months to months × sign.
  16. Set weeks to weeks × sign.
  17. Set days to days × sign.
  18. Set hours to hours × sign.
  19. Set minutes to minutes × sign.
  20. Set seconds to seconds × sign.
  21. Set milliseconds to milliseconds × sign.
  22. Set microseconds to microseconds × sign.
  23. Set nanoseconds to nanoseconds × sign.
  24. If nanoseconds < 0, then
    1. Set microseconds to microseconds + floor(nanoseconds / 1000).
    2. Set nanoseconds to ! NonNegativeModulo(nanoseconds, 1000).
  25. If microseconds < 0, then
    1. Set milliseconds to milliseconds + floor(microseconds / 1000).
    2. Set microseconds to ! NonNegativeModulo(microseconds, 1000).
  26. If milliseconds < 0, then
    1. Set seconds to seconds + floor(milliseconds / 1000).
    2. Set milliseconds to ! NonNegativeModulo(milliseconds, 1000).
  27. If seconds < 0, then
    1. Set minutes to minutes + floor(seconds / 60).
    2. Set seconds to ! NonNegativeModulo(seconds, 60).
  28. If minutes < 0, then
    1. Set hours to hours + floor(minutes / 60).
    2. Set minutes to ! NonNegativeModulo(minutes, 60).
  29. If hours < 0, then
    1. Set days to days + floor(hours / 24).
    2. Set hours to ! NonNegativeModulo(hours, 24).
  30. If any of months, weeks, days is negative, then
    1. Throw a RangeError.
  31. Set years to years × sign.
  32. Set months to months × sign.
  33. Set weeks to weeks × sign.
  34. Set days to days × sign.
  35. Set hours to hours × sign.
  36. Set minutes to minutes × sign.
  37. Set seconds to seconds × sign.
  38. Set milliseconds to milliseconds × sign.
  39. Set microseconds to microseconds × sign.
  40. Set nanoseconds to nanoseconds × sign.
  41. Return ? RegulateDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, overflow).

6.4.12 RoundDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , relativeTo ] )

  1. Let years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, and increment each be the mathematical values of themselves.
  2. If unit is "years", "months", or "weeks", then
    1. If relativeTo is not given, then
      1. Throw a RangeError exception.
    2. Else,
      1. Perform ? RequireInternalSlot(relativeTo, [[InitializedTemporalDateTime]]).
      2. Let calendar be relativeTo.[[Calendar]].
      3. Let dateMinus be ? Get(calendar, "dateMinus").
      4. Let options be ? ObjectCreate(%Object.prototype%).
  3. Let fractionalSeconds be nanoseconds × 10−9 + microseconds × 10−6 + milliseconds × 10−3 + seconds.
  4. Let fractionalDays be ((fractionalSeconds ÷ 60 + minutes) ÷ 60 + hours) ÷ 24 + days.
  5. If unit is "years", then
    1. Let yearsDuration be ? CreateTemporalDuration(years, 0, 0, 0, 0, 0, 0, 0, 0, 0).
    2. Let yearsBefore be ? Call(dateMinus, calendar, « relativeTo, yearsDuration, options, %Temporal.Date%).
    3. Let yearsMonthsWeeks be ? CreateTemporalDuration(years, months, weeks, 0, 0, 0, 0, 0, 0, 0).
    4. Let yearsMonthsWeeksBefore be ? Call(dateMinus, calendar, « relativeTo, yearsMonthsWeeks, options, %Temporal.Date%).
    5. Let monthsWeeksInDays be ? DifferenceDate(yearsMonthsWeeksBefore.[[ISOYear]], yearsMonthsWeeksBefore.[[ISOMonth]], yearsMonthsWeeksBefore.[[ISODay]], yearsBefore.[[ISOYear]], yearsBefore.[[ISOMonth]], yearsBefore.[[ISODay]], "days").
    6. Let days be days + monthsWeeksInDays.[[Days]].
    7. Let oneYear be ? CreateTemporalDuration(1, 0, 0, 0, 0, 0, 0, 0, 0, 0).
    8. Set relativeTo to ? Call(dateMinus, calendar, « relativeTo, oneYear, options, %Temporal.Date% »).
    9. Let daysInYear be ? Get(calendar, "daysInYear").
    10. Let oneYearDays be ? Call(daysInYear, calendar, « relativeTo »).
    11. Assert: daysoneYearDays. Note this will not be true in Temporal.Duration.prototype.round, this will become a loop.
    12. Let fractionalYears be years + days ÷ oneYearDays.
    13. Set years to ? RoundNumberToIncrement(fractionalYears, increment, roundingMode).
    14. Set months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.
  6. Else if unit is "months", then
    1. Let yearsMonths be ? CreateTemporalDuration(years, months, 0, 0, 0, 0, 0, 0, 0, 0).
    2. Let yearsMonthsBefore be ? Call(dateMinus, calendar, « relativeTo, yearsMonths, options, %Temporal.Date%).
    3. Let yearsMonthsWeeks be ? CreateTemporalDuration(years, months, weeks, 0, 0, 0, 0, 0, 0, 0).
    4. Let yearsMonthsWeeksBefore be ? Call(dateMinus, calendar, « relativeTo, yearsMonthsWeeks, options, %Temporal.Date%).
    5. Let weeksInDays be ? DifferenceDate(yearsMonthsWeeksBefore.[[ISOYear]], yearsMonthsWeeksBefore.[[ISOMonth]], yearsMonthsWeeksBefore.[[ISODay]], yearsMonthsBefore.[[ISOYear]], yearsMonthsBefore.[[ISOMonth]], yearsMonthsBefore.[[ISODay]], "days").
    6. Let days be days + weeksInDays.[[Days]].
    7. Let oneMonth be ? CreateTemporalDuration(0, 1, 0, 0, 0, 0, 0, 0, 0, 0).
    8. Set relativeTo to ? Call(dateMinus, calendar, « relativeTo, oneMonth, options, %Temporal.Date% »).
    9. Let daysInMonth be ? Get(calendar, "daysInMonth").
    10. Let oneMonthDays be ? Call(daysInMonth, calendar, « relativeTo »).
    11. Assert: daysoneMonthDays. Note this will not be true in Temporal.Duration.prototype.round, this will become a loop.
    12. Let fractionalMonths be months + days ÷ oneMonthDays.
    13. Set months to ? RoundNumberToIncrement(fractionalMonths, increment, roundingMode).
    14. Set weeks, days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.
  7. Else if unit is "weeks", then
    1. Let oneWeek be ? CreateTemporalDuration(0, 0, 1, 0, 0, 0, 0, 0, 0, 0).
    2. Set relativeTo to ? Call(dateMinus, calendar, « relativeTo, oneWeek, options, %Temporal.Date% »).
    3. Let daysInWeek be ? Get(calendar, "daysInWeek").
    4. Let oneWeekDays be ? Call(daysInWeek, calendar, « relativeTo »).
    5. Assert: daysoneWeekDays. Note this will not be true in Temporal.Duration.prototype.round, this will become a loop.
    6. Let fractionalWeeks be weeks + fractionalDays ÷ oneWeekDays.
    7. Set weeks to ? RoundNumberToIncrement(fractionalWeeks, increment, roundingMode).
    8. Set days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.
  8. Else if unit is "days", then
    1. Set days to ? RoundNumberToIncrement(fractionalDays, increment, roundingMode).
    2. Set hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.
  9. Else if unit is "hours", then
    1. Let fractionalHours be (fractionalSeconds ÷ 60 + minutes) ÷ 60 + hours.
    2. Set hours to ? RoundNumberToIncrement(fractionalHours, increment, roundingMode).
    3. Set minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.
  10. Else if unit is "minutes", then
    1. Let fractionalMinutes be fractionalSeconds ÷ 60 + minutes.
    2. Set minutes to ? RoundNumberToIncrement(fractionalMinutes, increment, roundingMode).
    3. Set seconds, milliseconds, microseconds, and nanoseconds to 0.
  11. Else if unit is "seconds", then
    1. Set seconds to ? RoundNumberToIncrement(fractionalSeconds, increment, roundingMode).
    2. Set milliseconds, microseconds, and nanoseconds to 0.
  12. Else if unit is "milliseconds", then
    1. Let fractionalMilliseconds be nanoseconds × 10−6 + microseconds × 10−3 + milliseconds.
    2. Set milliseconds to ? RoundNumberToIncrement(fractionalMilliseconds, increment, roundingMode).
    3. Set microseconds and nanoseconds to 0.
  13. Else if unit is "microseconds", then
    1. Let fractionalMicroseconds be nanoseconds × 10−3 + microseconds.
    2. Set microseconds to ? RoundNumberToIncrement(fractionalMicroseconds, increment, roundingMode).
    3. Set nanoseconds to 0.
  14. Else,
    1. Assert: unit is "nanoseconds".
    2. Set nanoseconds to ? RoundNumberToIncrement(nanoseconds, increment, roundingMode).
  15. Return the new Record { [[Years]]: years, [[Months]]: months, [[Weeks]]: weeks, [[Days]]: days, [[Hours]]: hours, [[Minutes]]: minutes, [[Seconds]]: seconds, [[Milliseconds]]: milliseconds, [[Microseconds]]: microseconds, [[Nanoseconds]]: nanoseconds }.

6.4.13 ToLimitedTemporalDuration ( temporalDurationLike, disallowedFields )

  1. If Type(temporalDurationLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let duration be ? ToTemporalDurationRecord(temporalDurationLike).
  3. If ! ValidateTemporalDuration(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]) is false, then
    1. Throw a RangeError exception.
  4. For each row of Table 4, except the header row, in table order, do
    1. Let prop be the Property value of the current row.
    2. Let value be duration's internal slot whose name is the Internal Slot value of the current row.
    3. If value is not 0 and disallowedFields contains prop, then
      1. Throw a RangeError exception.
  5. Return duration.

6.4.14 TemporalDurationToString ( duration )

  1. Let years be duration.[[Years]].
  2. Let months be duration.[[Months]].
  3. Let weeks be duration.[[Weeks]].
  4. Let days be duration.[[Days]].
  5. Let hours be duration.[[Hours]].
  6. Let minutes be duration.[[Minutes]].
  7. Let seconds be duration.[[Seconds]].
  8. Let milliseconds be duration.[[Milliseconds]].
  9. Let microseconds be duration.[[Microseconds]].
  10. Let nanoseconds be duration.[[Nanoseconds]].
  11. Let sign be ! DurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  12. Set microseconds to microseconds + the integral part of nanoseconds ÷ 1000.
  13. Set nanoseconds to nanoseconds modulo 1000.
  14. Set milliseconds to milliseconds + the integral part of microseconds ÷ 1000.
  15. Set microseconds to microseconds modulo 1000.
  16. Set seconds to seconds + the integral part of milliseconds ÷ 1000.
  17. Set milliseconds to milliseconds modulo 1000.
  18. If years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds are all 0, then
    1. Return the string "PT0S".
  19. Let datePart be "".
  20. If years is not 0, then
    1. Set datePart to the string concatenation of abs(years) formatted as a decimal number and the code unit 0x0059 (LATIN CAPITAL LETTER Y).
  21. If months is not 0, then
    1. Set datePart to the string concatenation of datePart, abs(months) formatted as a decimal number, and the code unit 0x004D (LATIN CAPITAL LETTER M).
  22. If weeks is not 0, then
    1. Set datePart to the string concatenation of datePart, abs(weeks) formatted as a decimal number, and the code unit 0x0057 (LATIN CAPITAL LETTER W).
  23. If days is not 0, then
    1. Set datePart to the string concatenation of datePart, abs(days) formatted as a decimal number, and the code unit 0x0044 (LATIN CAPITAL LETTER D).
  24. Let timePart be "".
  25. If hours is not 0, then
    1. Set timePart to the string concatenation of abs(hours) formatted as a decimal number and the code unit 0x0048 (LATIN CAPITAL LETTER H).
  26. If minutes is not 0, then
    1. Set timePart to the string concatenation of timePart, abs(minutes) formatted as a decimal number, and the code unit 0x004D (LATIN CAPITAL LETTER M).
  27. Let secondsPart be ! FormatSecondsStringPart(abs(seconds), abs(milliseconds), abs(microseconds), abs(nanoseconds)).
  28. If the first code unit of secondsPart is 0x003A (COLON), then
    1. Set secondsPart to the string containing all the code units of secondsPart except the first.
  29. If secondsPart is not "", then
    1. Set secondsPart to the string concatenation of secondsPart and the code unit 0x0053 (LATIN CAPITAL LETTER S).
  30. Let signPart be the code unit 0x002D (HYPHEN-MINUS) if sign < 0, and otherwise the empty String.
  31. Let result be the string concatenation of signPart, the code unit 0x0050 (LATIN CAPITAL LETTER P) and datePart.
  32. If timePart is not "", then
    1. Set result to the string concatenation of result, the code unit 0x0054 (LATIN CAPITAL LETTER T), timePart, and secondsPart.
  33. Return result.
Table 4: Properties of a TemporalDurationLike
Internal Slot Property
[[Days]] "days"
[[Hours]] "hours"
[[Microseconds]] "microseconds"
[[Milliseconds]] "milliseconds"
[[Minutes]] "minutes"
[[Months]] "months"
[[Nanoseconds]] "nanoseconds"
[[Seconds]] "seconds"
[[Weeks]] "weeks"
[[Years]] "years"

7 Temporal.Absolute Objects

A Temporal.Absolute object is an immutable Object referencing a point in time with nanoseconds precision.

7.1 The Temporal.Absolute Constructor

The Temporal.Absolute constructor is the %Temporal.Absolute% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.Absolute object.

The Temporal.Absolute constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Absolute behaviour must include a super call to the %Temporal.Absolute% constructor to create and initialize subclass instances with the necessary internal slots.

7.1.1 Temporal.Absolute ( epochNanoseconds )

When the Temporal.Absolute function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let epochNanoseconds be ? ToBigInt(epochNanoseconds).
  3. Perform ? RejectAbsolute(epochNanoseconds).
  4. Return ? CreateTemporalAbsolute(epochNanoseconds, NewTarget).

7.2 Properties of the Temporal.Absolute Constructor

The value of the [[Prototype]] internal slot of the Temporal.Absolute constructor is the intrinsic object %FunctionPrototype%.

The Temporal.Absolute constructor has the following properties:

7.2.1 Temporal.Absolute.prototype

The initial value of Temporal.Absolute.prototype is %Temporal.Absolute.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

7.2.2 get Temporal.Absolute [ @@species ]

Temporal.Absolute[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

7.2.3 Temporal.Absolute.from ( item )

The from method takes one argument item. The following steps are taken:

  1. If Type(arg) is Object and arg has an [[InitializedTemporalAbsolute]] internal slot, then
    1. Let absolute be arg.[[Nanoseconds]].
  2. Else,
    1. Let string be ? ToString(arg).
    2. Let absolute be ? ParseTemporalAbsolute(string).
  3. Let constructor be the this value.
  4. Return ? CreateTemporalAbsoluteFromStatic(constructor, absolute).

7.2.4 Temporal.Absolute.fromEpochSeconds ( epochSeconds )

The fromEpochSeconds method takes one argument epochSeconds. The following steps are taken:

  1. Set epochSeconds to ? ToNumber(epochSeconds).
  2. Set epochSeconds to ? NumberToBigInt(epochSeconds).
  3. Let epochNanoseconds be epochSeconds × 1,000,000,000.
  4. Perform ? RejectAbsolute(epochNanoseconds).
  5. Let constructor be the this value.
  6. Return ? CreateTemporalAbsoluteFromStatic(constructor, epochNanoseconds).

7.2.5 Temporal.Absolute.fromEpochMilliseconds ( epochMilliseconds )

The fromEpochMilliseconds method takes one argument epochMilliseconds. The following steps are taken:

  1. Set epochMilliseconds to ? ToNumber(epochMilliseconds).
  2. Set epochMilliseconds to ? NumberToBigInt(epochMilliseconds).
  3. Let epochNanoseconds be epochMilliseconds × 1,000,000.
  4. Perform ? RejectAbsolute(epochNanoseconds).
  5. Let constructor be the this value.
  6. Return ? CreateTemporalAbsoluteFromStatic(constructor, epochNanoseconds).

7.2.6 Temporal.Absolute.fromEpochMicroseconds ( epochMicroseconds )

The fromEpochMicroseconds method takes one argument epochMicroseconds. The following steps are taken:

  1. Set epochMicroseconds to ? ToBigInt(epochMicroseconds).
  2. Let epochNanoseconds be epochMicroseconds × 1,000.
  3. Perform ? RejectAbsolute(epochNanoseconds).
  4. Let constructor be the this value.
  5. Return ? CreateTemporalAbsoluteFromStatic(constructor, epochNanoseconds).

7.2.7 Temporal.Absolute.fromEpochNanoseconds ( epochNanoseconds )

The fromEpochNanoseconds method takes one argument epochNanoseconds. The following steps are taken:

  1. Set epochNanoseconds to ? ToBigInt(epochNanoseconds).
  2. Perform ? RejectAbsolute(epochNanoseconds).
  3. Let constructor be the this value.
  4. Return ? CreateTemporalAbsoluteFromStatic(constructor, epochNanoseconds).

7.2.8 Temporal.Absolute.compare ( one, two )

The compare method takes two arguments, one and two. The following steps are taken:

  1. Perform ? RequireInternalSlot(one, [[InitializedTemporalAbsolute]]).
  2. Perform ? RequireInternalSlot(two, [[InitializedTemporalAbsolute]]).
  3. Return ! CompareTemporalAbsolute(one, two).

7.3 Properties of the Temporal.Absolute Prototype Object

The Temporal.Absolute prototype object

  • is the intrinsic object %Temporal.Absolute.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.Absolute instance and does not have a [[InitializedTemporalAbsolute]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

7.3.1 Temporal.Absolute.prototype.constructor

The initial value of Temporal.Absolute.prototype.constructor is %Temporal.Absolute%.

7.3.2 Temporal.Absolute.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.Absolute".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

7.3.3 Temporal.Absolute.prototype.getEpochSeconds ( )

The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let ns be absolute.[[Nanoseconds]].
  4. Let s be RoundTowardsZero(ns / 1,000,000,000).
  5. Return the Number value for s.

7.3.4 Temporal.Absolute.prototype.getEpochMilliseconds ( )

The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let ns be absolute.[[Nanoseconds]].
  4. Let ms be RoundTowardsZero(ns / 1,000,000).
  5. Return the Number value for ms.

7.3.5 Temporal.Absolute.prototype.getEpochMicroseconds ( )

The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let ns be absolute.[[Nanoseconds]].
  4. Let mcs be RoundTowardsZero(ns / 1,000).
  5. Return mcs.

7.3.6 Temporal.Absolute.prototype.getEpochNanoseconds ( )

The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let ns be absolute.[[Nanoseconds]].
  4. Return ns.

7.3.7 Temporal.Absolute.prototype.plus ( temporalDurationLike )

The plus method takes one argument temporalDurationLike. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « "years", "months", "weeks", "days" »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let ns be absolute.[[Nanoseconds]] + duration.[[Nanoseconds]] + duration.[[Microseconds]] × 1000 + duration.[[Milliseconds]] × 1,000,000 + duration.[[Seconds]] × 1,000,000,000 + duration.[[Minutes]] × 60,000,000,000 + duration.[[Hours]] × 3,600,000,000,000.
  6. Perform ? RejectAbsolute(ns).
  7. Return ? CreateTemporalAbsoluteFromInstance(absolute, ns).

7.3.8 Temporal.Absolute.prototype.minus ( temporalDurationLike )

The minus method takes one argument temporalDurationLike. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « "years", "months", "weeks", "days" »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let ns be absolute.[[Nanoseconds]] - duration.[[Nanoseconds]] - duration.[[Microseconds]] × 1000 - duration.[[Milliseconds]] × 1,000,000 - duration.[[Seconds]] × 1,000,000,000 - duration.[[Minutes]] × 60,000,000,000 - duration.[[Hours]] × 3,600,000,000,000.
  6. Perform ? RejectAbsolute(ns).
  7. Return ? CreateTemporalAbsoluteFromInstance(absolute, ns).

7.3.9 Temporal.Absolute.prototype.difference ( other [ , options ] )

The difference method takes two arguments, other and options. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalAbsolute]]).
  4. Let smallestUnit be ? ToSmallestTemporalDurationUnit(options, « "years", "months", "weeks", "days" », "nanoseconds").
  5. If smallestUnit is "hours" or "minutes", then
    1. Let defaultLargestUnit be smallestUnit.
  6. Else,
    1. Let defaultLargestUnit be "seconds".
  7. Let largestUnit be ? ToLargestTemporalUnit(options, « "years", "months", "weeks", "days" », defaultLargestUnit).
  8. Perform ? ValidateTemporalDifferenceUnits(largestUnit, smallestUnit).
  9. Let roundingMode be ? ToTemporalRoundingMode(options).
  10. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  11. Let roundingIncrement be the mathematical value of ? ToTemporalRoundingIncrement(options, maximum, false).
  12. If smallestUnit is "hours", then
    1. Let incrementNs be roundingIncrement × 3.6 × 1012.
  13. If smallestUnit is "minutes", then
    1. Let incrementNs be roundingIncrement × 6 × 1010.
  14. Else if smallestUnit is "seconds", then
    1. Let incrementNs be roundingIncrement × 109.
  15. Else if smallestUnit is "milliseconds", then
    1. Let incrementNs be roundingIncrement × 106.
  16. Else if smallestUnit is "microseconds", then
    1. Let incrementNs be roundingIncrement × 103.
  17. Else,
    1. Assert: smallestUnit is "nanoseconds".
    2. Let incrementNs be roundingIncrement.
  18. Let ns be the mathematical value of absolute.[[Nanoseconds]] − otherAbsolute.[[Nanoseconds]].
  19. Let roundedNs be ? RoundNumberToIncrement(diff, incrementNs, roundingMode).
  20. Let result be ! BalanceDuration(0, 0, 0, 0, 0, 0, roundedNs, largestUnit).
  21. Return ? CreateTemporalDuration(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

7.3.10 Temporal.Absolute.prototype.round ( options )

The round method takes one argument, options. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let smallestUnit be ? ToSmallestTemporalUnit(options, « "day", "hour" »).
  4. Let roundingMode be ? ToTemporalRoundingMode(options).
  5. If smallestUnit is "minute", then
    1. Let maximum be 1440.
  6. Else if smallestUnit is "second", then
    1. Let maximum be 86400.
  7. Else if smallestUnit is "millisecond", then
    1. Let maximum be 8.64 × 107.
  8. Else if smallestUnit is "microsecond", then
    1. Let maximum be 8.64 × 1010.
  9. Else,
    1. Assert: smallestUnit is "nanosecond".
    2. Let maximum be 8.64 × 1013.
  10. Let roundingIncrement be the mathematical value of ? ToTemporalRoundingIncrement(options, maximum, true).
  11. If smallestUnit is "minute", then
    1. Let incrementNs be roundingIncrement × 6 × 1010.
  12. Else if smallestUnit is "second", then
    1. Let incrementNs be roundingIncrement × 109.
  13. Else if smallestUnit is "millisecond", then
    1. Let incrementNs be roundingIncrement × 106.
  14. Else if smallestUnit is "microsecond", then
    1. Let incrementNs be roundingIncrement × 103.
  15. Else,
    1. Let incrementNs be roundingIncrement.
  16. Let ns be the mathematical value of absolute.[[Nanoseconds]].
  17. Let roundedNs be ? RoundNumberToIncrement(ns, incrementNs, roundingMode).
  18. Return ? CreateTemporalAbsoluteFromInstance(absolute, roundedNs).

7.3.11 Temporal.Absolute.prototype.equals ( other )

The equals method takes one argument other. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalAbsolute]]).
  4. If absolute.[[Nanoseconds]] ≠ other.[[Nanoseconds]], return false.
  5. Return true.

7.3.12 Temporal.Absolute.prototype.toString ( [ temporalTimeZoneLike ] )

The toString method takes one argument temporalTimeZoneLike. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. If temporalTimeZoneLike is undefined, then
    1. Set temporalTimeZoneLike to "UTC".
  4. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  5. Return ? TemporalAbsoluteToString(absolute, timeZone).

7.3.13 Temporal.Absolute.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. If the implementation does not include the ECMA-402 Internationalization API, then
    1. Let timeZone be ? CreateTemporalTimeZone("UTC").
    2. Return ? TemporalAbsoluteToString(absolute, timeZone).
  4. Let dateFormat be ? Construct(%DateTimeFormat%, « locales, options »).
  5. Return ? FormatDateTime(dateFormat, absolute).

7.3.14 Temporal.Absolute.prototype.toJSON ( )

The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let timeZone be ? CreateTemporalTimeZone("UTC").
  4. Return ? TemporalAbsoluteToString(absolute, timeZone).

7.3.15 Temporal.Absolute.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

7.3.16 Temporal.Absolute.prototype.toDateTime ( temporalTimeZoneLike [ , calendarLike ] )

The toDateTime method takes two arguments, temporalTimeZoneLike and calendar. The following steps are taken:

  1. Let absolute be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  4. If calendarLike is undefined, then
    1. Let calendar be ! GetDefaultCalendar().
  5. Else,
    1. Let calendar be ? ToTemporalCalendar(calendarLike).
  6. Return ? GetTemporalDateTimeFor(timeZone, absolute, calendar).

7.4 Abstract operations

7.4.1 ValidateAbsolute ( ns )

  1. Assert: Type(ns) is BigInt.
  2. If ns < −8.64 × 1021 or ns > 8.64 × 1021, then
    1. Return false.
  3. Return true.

7.4.2 RejectAbsolute ( ns )

  1. Assert: Type(ns) is BigInt.
  2. If ! ValidateAbsolute(ns) is false, then
    1. Throw a RangeError exception.

7.4.3 CreateTemporalAbsolute ( ns [ , newTarget ] )

  1. Assert: Type(ns) is BigInt.
  2. Assert: ! ValidateAbsolute(ns) is true.
  3. If newTarget is not given, set it to %Temporal.Absolute%.
  4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Absolute.prototype%", « [[InitializedTemporalAbsolute]], [[Nanoseconds]] »).
  5. Set object.[[Nanoseconds]] to ns.
  6. Return object.

7.4.4 CreateTemporalAbsoluteFromStatic ( constructor, ns )

  1. Assert: ! ValidateAbsolute(ns) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « ns »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalAbsolute]]).
  5. Return result.

7.4.5 CreateTemporalAbsoluteFromInstance ( absolute, ns )

  1. Assert: Type(absolute) is Object and absolute has an [[InitializedTemporalAbsolute]] internal slot.
  2. Assert: ! ValidateAbsolute(ns) is true.
  3. Let constructor be ? SpeciesConstructor(absolute, %Temporal.Absolute%).
  4. Let result be ? Construct(constructor, « ns »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalAbsolute]]).
  6. Return result.

7.4.6 ParseTemporalAbsolute ( isoString )

  1. Assert: Type(isoString) is String.
  2. Let result be ? ParseTemporalAbsoluteString(isoString).
  3. Let dateTime be ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[microsecond]], result.[[Nanosecond]]).
  4. Let timeZone be ? TimeZoneFrom(result.[[TimeZoneName]]).
  5. Let possibleAbsolutes be ? GetPossibleAbsolutesFor(timeZone, dateTime).
  6. If possibleAbsolutes's length is 1, then
    1. Return possibleAbsolutes[0].[[Nanoseconds]].
  7. TODO: Disambiguate using result.[[TimeZoneOffsetSign]], result.[[TimeZoneOffsetHour]] and result.[[TimeZoneOffsetMinute]].
  8. Return TODO.

7.4.7 CompareTemporalAbsolute ( one, two )

  1. Assert: Type(one) is Object.
  2. Assert: one has an [[InitializedTemporalAbsolute]] internal slot.
  3. Assert: Type(two) is Object.
  4. Assert: two has an [[InitializedTemporalAbsolute]] internal slot.
  5. If one.[[Nanoseconds]] > two.[[Nanoseconds]], return 1.
  6. If one.[[Nanoseconds]] < two.[[Nanoseconds]], return -1.
  7. Return +0.

7.4.8 TemporalAbsoluteToString ( absolute, timeZone )

  1. Assert: Type(absolute) is Object.
  2. Assert: absolute has an [[InitializedTemporalAbsolute]] internal slot.
  3. Let dateTime be ? GetTemporalDateTimeFor(timeZone, absolute).
  4. Let dateTimeString be ! TemporalDateTimeToString(dateTime).
  5. Let timeZoneString be ? ISOTimeZoneString(timeZone, absolute).
  6. Return the string-concatenation of dateTimeString and timeZoneString.

7.4.9 ISOTimeZoneString ( absolute, timeZone )

  1. Assert: Type(absolute) is Object.
  2. Assert: absolute has an [[InitializedTemporalAbsolute]] internal slot.
  3. Assert?: Type(timeZone) is Object.
  4. Let name be ? TimeZoneToString(timeZone).
  5. Let offset be ? GetOffsetStringFor(timeZone, absolute).
  6. If name is "UTC", then
    1. Return "Z".
  7. If name is offset, then
    1. Return offset.
  8. Return the string-concatenation of offset, "[", name, and "]".

8 Temporal.YearMonth Objects

A Temporal.YearMonth object is an immutable Object that contains Number values corresponding to a particular year and month.

8.1 The Temporal.YearMonth Constructor

The Temporal.YearMonth constructor is the %Temporal.YearMonth% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.YearMonth object.

The Temporal.YearMonth constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified YearMonth behaviour must include a super call to the %Temporal.YearMonth% constructor to create and initialize subclass instances with the necessary internal slots.

8.1.1 Temporal.YearMonth ( isoYear, isoMonth [ , refISODay ] )

When the Temporal.YearMonth function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. If refISODay is not given, set it to 1.
  3. Let y be ? ToInteger(isoYear).
  4. Let m be ? ToInteger(isoMonth).
  5. Let ref be ? ToInteger(refISODay).
  6. Return ? CreateTemporalYearMonth(y, m, ref, NewTarget).

8.2 Properties of the Temporal.YearMonth Constructor

The value of the [[Prototype]] internal slot of the Temporal.YearMonth constructor is the intrinsic object %FunctionPrototype%.

The Temporal.YearMonth constructor has the following properties:

8.2.1 Temporal.YearMonth.prototype

The initial value of Temporal.YearMonth.prototype is %Temporal.YearMonth.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

8.2.2 get Temporal.YearMonth [ @@species ]

Temporal.YearMonth[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

8.2.3 Temporal.YearMonth.from ( item [ , options ] )

The from method takes two arguments, item and options. The following steps are taken:

  1. Let overflow be ? ToTemporalOverflow(options).
  2. If Type(item) is Object, then
    1. Let result be ? ToTemporalYearMonthRecord(item).
    2. Let refISODay be result.[[Day]].
  3. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalYearMonthString(string).
    3. Let refISODay be 1.
  4. Let constructor be the this value.
  5. Set result to ? RegulateYearMonth(result.[[Year]], result.[[Month]], overflow).
  6. Return ? CreateTemporalYearMonthFromStatic(constructor, result.[[Year]], result.[[Month]], refISODay).

8.2.4 Temporal.YearMonth.compare ( one, two )

The compare method takes two arguments, one and two. The following steps are taken:

  1. Perform ? RequireInternalSlot(one, [[InitializedTemporalYearMonth]]).
  2. Perform ? RequireInternalSlot(two, [[InitializedTemporalYearMonth]]).
  3. Return ! CompareTemporalDate(one.[[ISOYear]], one.[[ISOMonth]], one.[[RefISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[RefISODay]]).

8.3 Properties of the Temporal.YearMonth Prototype Object

The Temporal.YearMonth prototype object

  • is the intrinsic object %Temporal.YearMonth.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.YearMonth instance and does not have a [[InitializedTemporalYearMonth]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

8.3.1 Temporal.YearMonth.prototype.constructor

The initial value of Temporal.YearMonth.prototype.constructor is %Temporal.YearMonth%.

8.3.2 Temporal.YearMonth.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.YearMonth".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

8.3.3 get Temporal.YearMonth.prototype.year

Temporal.YearMonth.prototype.year is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return yearMonth.[[ISOYear]].

8.3.4 get Temporal.YearMonth.prototype.month

Temporal.YearMonth.prototype.month is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return yearMonth.[[ISOMonth]].

8.3.5 get Temporal.YearMonth.prototype.daysInYear

Temporal.YearMonth.prototype.daysInYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return ! DaysInYear(yearMonth.[[ISOYear]]).

8.3.6 get Temporal.YearMonth.prototype.daysInMonth

Temporal.YearMonth.prototype.daysInMonth is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return ! DaysInMonth(yearMonth.[[ISOYear]], yearMonth.[[ISOMonth]]).

8.3.7 get Temporal.YearMonth.prototype.monthsInYear

Temporal.YearMonth.prototype.monthsInYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return 12.
  4. TODO: Make calendar-aware along with all the other properties.

8.3.8 get Temporal.YearMonth.prototype.isLeapYear

Temporal.YearMonth.prototype.isLeapYear is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return ! IsLeapYear(yearMonth.[[ISOYear]]).

8.3.9 Temporal.YearMonth.prototype.with ( temporalYearMonthLike [ , options ] )

The with method takes two arguments, temporalYearMonthLike and options. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Let partialYearMonth be ? ToPartialYearMonth(temporalYearMonthLike).
  4. Let overflow be ? ToTemporalOverflow(options).
  5. If partialYearMonth.[[Year]] is not undefined, then
    1. Let y be partialYearMonth.[[Year]].
  6. Else,
    1. Let y be yearMonth.[[ISOYear]].
  7. If partialYearMonth.[[Month]] is not undefined, then
    1. Let m be partialYearMonth.[[Month]].
  8. Else,
    1. Let m be yearMonth.[[ISOMonth]].
  9. Let result be ? RegulateYearMonth(y, m, overflow).
  10. Return ? CreateTemporalYearMonthFromInstance(yearMonth, result.[[Year]], result.[[Month]]).

8.3.10 Temporal.YearMonth.prototype.plus ( temporalDurationLike [ , options ] )

The plus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let balanceResult be ? BalanceDuration(duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "days").
  6. Let overflow be ? ToTemporalOverflow(options).
  7. Let sign be ! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], _balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
  8. If sign < 0, then
    1. Let day be ! DaysInMonth(_yearMonth.[[ISOYear]], yearMonth.[[ISOMonth]]).
  9. Else,
    1. Let day be 1.
  10. Let result be ? AddDate(yearMonth.[[ISOYear]], yearMonth.[[ISOMonth]], day, duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], overflow).
  11. Let result be ? RegulateYearMonth(result.[[Year]], result.[[Month]], overflow).
  12. Return ? CreateTemporalYearMonthFromInstance(yearMonth, result.[[Year]], result.[[Month]]).

8.3.11 Temporal.YearMonth.prototype.minus ( temporalDurationLike [ , options ] )

The minus method takes two arguments, temporalDurationLike and options. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Perform ? RejectDurationSign(duration.[[Years]], _duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Let balanceResult be ? BalanceDuration(duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "days").
  6. Let overflow be ? ToTemporalOverflow(options).
  7. Let sign be ! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], _balanceResult.[[Days]], 0, 0, 0, 0, 0, 0).
  8. If sign < 0, then
    1. Let day be 1.
  9. Else,
    1. Let day be ! DaysInMonth(_yearMonth.[[ISOYear]], yearMonth.[[ISOMonth]]).
  10. Let result be ? SubtractDate(yearMonth.[[ISOYear]], yearMonth.[[ISOMonth]], day, duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], overflow).
  11. Let result be ? RegulateYearMonth(result.[[Year]], result.[[Month]], overflow).
  12. Return ? CreateTemporalYearMonthFromInstance(yearMonth, result.[[Year]], result.[[Month]]).

8.3.12 Temporal.YearMonth.prototype.difference ( other [ , options ] )

The difference method takes two arguments, other and options. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalYearMonth]]).
  4. Let largestUnit be ? ToLargestTemporalUnit(options, « "weeks", "days", "hours", "minutes", "seconds", "milliesconds", "microseconds", "nanoseconds" », "years").
  5. Let years be yearMonth.[[ISOYear]] - other.[[ISOYear]].
  6. Let months be yearMonth.[[ISOMonth]] - other.[[ISOMonth]].
  7. If months < 0, then
    1. Set years to years - 1.
    2. Set months to months + 12.
  8. If largestUnit is "months", then
    1. Set months to months + years × 12.
    2. Set years to 0.
  9. Assert: months ≥ 0.
  10. Return ? CreateTemporalDuration(years, months, 0, 0, 0, 0, 0, 0, 0).

8.3.13 Temporal.YearMonth.prototype.equals ( other )

The equals method takes one argument other. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalYearMonth]]).
  4. If yearMonth.[[ISOYear]] ≠ other.[[ISOYear]], return false.
  5. If yearMonth.[[ISOMonth]] ≠ other.[[ISOMonth]], return false.
  6. If yearMonth.[[RefISODay]] ≠ other.[[RefISODay]], return false.
  7. Return true.

8.3.14 Temporal.YearMonth.prototype.toString ( )

The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return ! TemporalYearMonthToString(yearMonth).

8.3.15 Temporal.YearMonth.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. If the implementation does not include the ECMA-402 Internationalization API, then
    1. Return ! TemporalYearMonthToString(yearMonth).
  4. Let dateFormat be ? Construct(%DateTimeFormat%, « locales, options »).
  5. Return ? FormatDateTime(dateFormat, yearMonth).

8.3.16 Temporal.YearMonth.prototype.toJSON ( )

The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Return ! TemporalYearMonthToString(yearMonth).

8.3.17 Temporal.YearMonth.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

8.3.18 Temporal.YearMonth.prototype.toDateOnDay ( day )

The toDateOnDay method takes one argument day. The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Let d be ? ToInteger(day).
  4. Return ? CreateTemporalDate(yearMonth.[[ISOYear]], yearMonth.[[ISOMonth]], d).

8.3.19 Temporal.YearMonth.prototype.getFields ( )

The following steps are taken:

  1. Let yearMonth be the this value.
  2. Let record be ? ToPartialYearMonth(yearMonth).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. For each row of Table 5, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. Let v be the value of record's field whose name is the Internal Slot value of the current row.
    3. Perform ! CreateDataPropertyOrThrow(fields, p, v).
  5. Return fields.

8.3.20 Temporal.YearMonth.prototype.getISOFields ( )

The following steps are taken:

  1. Let yearMonth be the this value.
  2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", yearMonth.[[ISOYear]]).
  5. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", yearMonth.[[ISOMonth]]).
  6. Perform ! CreateDataPropertyOrThrow(fields, "refISODay", yearMonth.[[RefISODay]]).
  7. Perform ! CreateDataPropertyOrThrow(fields, "calendar", yearMonth.[[Calendar]]).
  8. Return fields.

8.4 Abstract operations

8.4.1 ToPartialYearMonth ( temporalYearMonthLike )

  1. If Type(temporalYearMonthLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let result be the new Record { [[Year]]: undefined, [[Month]]: undefined }.
  3. Let any be false.
  4. For each row of Table 5, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalYearMonthLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToInteger(value).
      3. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. If any is false, then
    1. Throw a TypeError exception.
  6. Return result.
Table 5: Properties of a TemporalYearMonthLike
Internal Slot Property
[[Month]] "month"
[[Year]] "year"

8.4.2 RegulateYearMonth ( year, month, overflow )

  1. Assert: year and month are integer Number values.
  2. Assert: overflow is either "constrain" or "reject".
  3. If overflow is "constrain", then
    1. Return ! ConstrainYearMonth(year, month).
  4. If overflow is "reject", then
    1. If ! ValidateYearMonth(year, month) is false, then
      1. Throw a RangeError exception.
    2. Return the new Record { [[Year]]: year, [[Month]]: month }.

8.4.3 ValidateYearMonth ( year, month )

  1. Assert: year and month are integer Number values.
  2. If month < 1 or month > 12, then
    1. Return false.
  3. Return true.

8.4.4 ValidateYearMonthRange ( year, month )

  1. Assert: year and month are integer Number values.
  2. If year < −271821 or year > 275760, then
    1. Return false.
  3. If year is −271821 and month < 4, then
    1. Return false.
  4. If year is 275760 and month > 9, then
    1. Return false.
  5. Return true.

8.4.5 BalanceYearMonth ( year, month )

  1. Assert: year and month are integer Number values.
  2. If year is +∞ or −∞, or month is +∞ or −∞, then
    1. Throw a RangeError exception.
  3. Set year to year + floor((month - 1) / 12).
  4. Set month to NonNegativeModulo(month - 1, 12) + 1.
  5. Return the new Record { [[Year]]: year, [[Month]]: month }.

8.4.6 ConstrainYearMonth ( year, month )

  1. Assert: year and month are integer Number values.
  2. Set month to ! ConstrainToRange(month, 1, 12).
  3. Return the Record { [[Year]]: year, [[Month]]: month }.

8.4.7 CreateTemporalYearMonth ( isoYear, isoMonth, refISODay [ , newTarget ] )

  1. If ! ValidateDate(isoYear, isoMonth, refISODay) is false, then
    1. Throw a RangeError exception.
  2. If ! ValidateYearMonthRange(isoYear, isoMonth) is false, then
    1. Throw a RangeError exception.
  3. If newTarget is not given, set it to %Temporal.YearMonth%.
  4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.YearMonth.prototype%", « [[InitializedTemporalYearMonth]], [[ISOYear]], [[ISOMonth]], [[RefISODay]] »).
  5. Set object.[[ISOYear]] to isoYear.
  6. Set object.[[ISOMonth]] to isoMonth.
  7. Set object.[[RefISODay]] to refISODay.
  8. Return object.

8.4.8 CreateTemporalYearMonthFromInstance ( yearMonth, isoYear, isoMonth )

  1. Assert: Type(yearMonth) is Object and yearMonth has an [[InitializedTemporalYearMonth]] internal slot.
  2. Assert: ! ValidateYearMonth(isoYear, isoMonth) is true.
  3. Let constructor be ? SpeciesConstructor(yearMonth, %Temporal.YearMonth%).
  4. Let result be ? Construct(constructor, « isoYear, isoMonth »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalYearMonth]]).
  6. Return result.

8.4.9 CreateTemporalYearMonthFromStatic ( constructor, year, month, refISODay )

  1. Assert: ! ValidateDate(year, month, refISODay) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « year, month, refISODay »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalYearMonth]]).
  5. Return result.

8.4.10 ToTemporalYearMonthRecord ( temporalYearMonthLike )

  1. Assert: Type(temporalYearMonthLike) is Object.
  2. If temporalYearMonthLike has an [[InitializedTemporalYearMonth]] internal slot, then
    1. Return the Record { [[Year]]: temporalYearMonthLike.[[Year]], [[Month]]: temporalYearMonthLike.[[Month]], [[Day]]: temporalYearMonthLike.[[RefISODay]] }.
  3. Let result be a new Record with all the internal slots given in the Internal Slot column in Table 5, as well as a [[Day]] slot.
  4. For each row of Table 5, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalYearMonthLike, property).
    3. If value is undefined, then
      1. Throw a TypeError exception.
    4. Let value be ? ToInteger(value).
    5. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. Set result.[[Day]] to 1.
  6. Return result.

8.4.11 TemporalYearMonthToString ( yearMonth )

  1. Assert: Type(yearMonth) is Object.
  2. Assert: yearMonth has an [[InitializedTemporalYearMonth]] internal slot.
  3. Let year be ! PadYear(yearMonth.[[ISOYear]]).
  4. Let month be yearMonth.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and month.

9 Temporal.MonthDay Objects

A Temporal.MonthDay object is an immutable Object that contains Number values corresponding to a particular year and month.

9.1 The Temporal.MonthDay Constructor

The Temporal.MonthDay constructor is the %Temporal.MonthDay% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.MonthDay object.

The Temporal.MonthDay constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified MonthDay behaviour must include a super call to the %Temporal.MonthDay% constructor to create and initialize subclass instances with the necessary internal slots.

9.1.1 Temporal.MonthDay ( isoMonth, isoDay [ , refISOYear ] )

When the Temporal.MonthDay function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. If refISOYear is not given, set it to the first leap year after the Unix epoch (1972).
  3. Let m be ? ToInteger(isoMonth).
  4. Let d be ? ToInteger(isoDay).
  5. Let ref be ? ToInteger(refISOYear).
  6. Return ? CreateTemporalMonthDay(m, d, ref, NewTarget).

9.2 Properties of the Temporal.MonthDay Constructor

The value of the [[Prototype]] internal slot of the Temporal.MonthDay constructor is the intrinsic object %FunctionPrototype%.

The Temporal.MonthDay constructor has the following properties:

9.2.1 Temporal.MonthDay.prototype

The initial value of Temporal.MonthDay.prototype is %Temporal.MonthDay.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

9.2.2 get Temporal.MonthDay [ @@species ]

Temporal.MonthDay[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

9.2.3 Temporal.MonthDay.from ( item [ , options ] )

The from method takes two arguments, item and options. The following steps are taken:

  1. Let overflow be ? ToTemporalOverflow(options).
  2. If Type(item) is Object, then
    1. Let result be ? ToTemporalMonthDayRecord(item).
    2. Let refISOYear be result.[[Year]].
  3. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalMonthDayString(string).
    3. Let refISOYear be the first leap year after the Unix epoch (1972).
  4. Let constructor be the this value.
  5. Set result to ? RegulateMonthDay(result.[[Month]], result.[[Day]], overflow).
  6. Return ? CreateTemporalMonthDayFromStatic(constructor, result.[[Month]], result.[[Day]], refISOYear).

9.3 Properties of the Temporal.MonthDay Prototype Object

The Temporal.MonthDay prototype object

  • is the intrinsic object %Temporal.MonthDay.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.MonthDay instance and does not have a [[InitializedTemporalMonthDay]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

9.3.1 Temporal.MonthDay.prototype.constructor

The initial value of Temporal.MonthDay.prototype.constructor is %Temporal.MonthDay%.

9.3.2 Temporal.MonthDay.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.MonthDay".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

9.3.3 get Temporal.MonthDay.prototype.month

Temporal.MonthDay.prototype.month is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Return monthDay.[[ISOMonth]].

9.3.4 get Temporal.MonthDay.prototype.day

Temporal.MonthDay.prototype.day is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Return monthDay.[[ISODay]].

9.3.5 Temporal.MonthDay.prototype.with ( temporalMonthDayLike [ , options ] )

The with method takes two arguments, temporalMonthDayLike and options. The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Let partialMonthDay be ? ToPartialMonthDay(temporalMonthDayLike).
  4. Let overflow be ? ToTemporalOverflow(options).
  5. If partialMonthDay.[[Month]] is not undefined, then
    1. Let m be partialMonthDay.[[Month]].
  6. Else,
    1. Let m be monthDay.[[ISOMonth]].
  7. If partialMonthDay.[[Day]] is not undefined, then
    1. Let d be partialMonthDay.[[Day]].
  8. Else,
    1. Let d be monthDay.[[ISODay]].
  9. Let result be ? RegulateMonthDay(m, d, overflow).
  10. Return ? CreateTemporalMonthDayFromInstance(monthDay, result.[[Month]], result.[[Day]]).

9.3.6 Temporal.MonthDay.prototype.equals ( other )

The equals method takes one argument other. The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Perform ? RequireInternalSlot(other, [[InitializedTemporalMonthDay]]).
  4. If monthDay.[[ISOMonth]] ≠ other.[[ISOMonth]], return false.
  5. If monthDay.[[ISODay]] ≠ other.[[ISODay]], return false.
  6. If monthDay.[[RefISOYear]] ≠ other.[[RefISOYear]], return false.
  7. Return true.

9.3.7 Temporal.MonthDay.prototype.toString ( )

The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Return ! TemporalMonthDayToString(monthDay).

9.3.8 Temporal.MonthDay.prototype.toLocaleString ( [ locales [ , options ] ] )

The toLocaleString method takes two arguments, locales and options. The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. If the implementation does not include the ECMA-402 Internationalization API, then
    1. Return ! TemporalMonthDayToString(monthDay).
  4. Let dateFormat be ? Construct(%DateTimeFormat%, « locales, options »).
  5. Return ? FormatDateTime(dateFormat, monthDay).

9.3.9 Temporal.MonthDay.prototype.toJSON ( )

The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Return ! TemporalMonthDayToString(monthDay).

9.3.10 Temporal.MonthDay.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

9.3.11 Temporal.MonthDay.prototype.toDateInYear ( item [ , options ] )

The toDateInYear method takes two arguments, item and options. The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Let overflow be ? ToTemporalOverflow(options).
  4. If Type(item) is Object, then
    1. Let y be ? Get(item, "year").
    2. If y is undefined, then
      1. Throw a TypeError exception.
    3. Let y be ? ToInteger(y).
  5. Else,
    1. Let y be ? ToInteger(item).
  6. Let date be ? RegulateDate(y, monthDay.[[ISOMonth]], monthDay.[[ISODay]], overflow).
  7. Return ? CreateTemporalDate(date.[[Year]], date.[[Month]], date.[[Day]]).

9.3.12 Temporal.MonthDay.prototype.getFields ( )

The following steps are taken:

  1. Let monthDay be the this value.
  2. Let record be ? ToPartialMonthDay(monthDay).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. For each row of Table 6, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. Let v be the value of record's field whose name is the Internal Slot value of the current row.
    3. Perform ! CreateDataPropertyOrThrow(fields, p, v).
  5. Return fields.

9.3.13 Temporal.MonthDay.prototype.getISOFields ( )

The following steps are taken:

  1. Let monthDay be the this value.
  2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
  3. Let fields be ? ObjectCreate(%ObjectPrototype%).
  4. Perform ! CreateDataPropertyOrThrow(fields, "refISOYear", monthDay.[[RefISOYear]]).
  5. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", monthDay.[[ISOMonth]]).
  6. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", monthDay.[[ISODay]]).
  7. Perform ! CreateDataPropertyOrThrow(fields, "calendar", monthDay.[[Calendar]]).
  8. Return fields.

9.4 Abstract operations

9.4.1 ToPartialMonthDay ( temporalMonthDayLike )

  1. If Type(temporalMonthDayLike) is not Object, then
    1. Throw a TypeError exception.
  2. Let result be the new Record { [[Month]]: undefined, [[Day]]: undefined }.
  3. Let any be false.
  4. For each row of Table 6, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalMonthDayLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToInteger(value).
      3. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. If any is false, then
    1. Throw a TypeError exception.
  6. Return result.
Table 6: Properties of a TemporalMonthDayLike
Internal Slot Property
[[Day]] "day"
[[Month]] "month"

9.4.2 RegulateMonthDay ( month, day, overflow )

  1. Assert: overflow is either "constrain" or "reject".
  2. If overflow is "reject", then
    1. Perform ? RejectMonthDay(month, day).
    2. Return the Record { [[Month]]: month, [[Day]]: day }.
  3. If overflow is "constrain", then
    1. Return ! ConstrainMonthDay(month, day).

9.4.3 ValidateMonthDay ( month, day )

  1. Assert: month and day are integer Number values.
  2. If month < 1 or month > 12, then
    1. Return false.
  3. Let leapYear be the first leap year after the Unix epoch (1972).
  4. Let maxDay be ! DaysInMonth(leapYear, m).
  5. If d < 1 or d > maxDay, then
    1. Return false.
  6. Return true.

9.4.4 RejectMonthDay ( month, day )

  1. Assert: month and day are integer Number values.
  2. If ! ValidateMonthDay(month, day) is false, then
    1. Throw a RangeError exception.

9.4.5 ConstrainMonthDay ( month, day )

  1. Assert: month and day are integer Number values.
  2. Let leapYear be the first leap year after the Unix epoch (1972).
  3. Let result be ! ConstrainDate(leapYear, month, day).
  4. Return the new Record { [[Month]]: result.[[Month]], [[Day]]: result.[[Day]] }.

9.4.6 CreateTemporalMonthDay ( isoMonth, isoDay, refISOYear [ , newTarget ] )

  1. If ! ValidateDate(refISOYear, month, day) is false, then
    1. Throw a RangeError exception.
  2. If newTarget is not given, set it to %Temporal.MonthDay%.
  3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.MonthDay.prototype%", « [[InitializedTemporalMonthDay]], [[ISOMonth]], [[ISODay]], [[RefISOYear]] »).
  4. Set object.[[ISOMonth]] to month.
  5. Set object.[[ISODay]] to day.
  6. Set object.[[RefISOYear]] to refISOYear.
  7. Return object.

9.4.7 CreateTemporalMonthDayFromInstance ( monthDay, isoMonth, isoDay )

  1. Assert: Type(monthDay) is Object and monthDay has an [[InitializedTemporalMonthDay]] internal slot.
  2. Assert: ! ValidateMonthDay(isoMonth, isoDay) is true.
  3. Let constructor be ? SpeciesConstructor(monthDay, %Temporal.MonthDay%).
  4. Let result be ? Construct(constructor, « isoMonth, isoDay »).
  5. Perform ? RequireInternalSlot(result, [[InitializedTemporalMonthDay]]).
  6. Return result.

9.4.8 CreateTemporalMonthDayFromStatic ( constructor, month, day, refISOYear )

  1. Assert: ! ValidateDate(refISOYear, month, day) is true.
  2. If ! IsConstructor(constructor) is false, then
    1. Throw a TypeError exception.
  3. Let result be ? Construct(constructor, « month, day, refISOYear »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalMonthDay]]).
  5. Return result.

9.4.9 ToTemporalMonthDayRecord ( temporalMonthDayLike )

  1. Assert: Type(temporalMonthDayLike) is Object.
  2. If temporalMonthDayLike has an [[InitializedTemporalMonthDay]] internal slot, then
    1. Return the Record { [[Month]]: temporalMonthDayLike.[[ISOMonth]], [[Day]]: temporalMonthDayLike.[[ISODay]], [[Year]]: temporalMonthDayLike.[[RefISOYear]] }.
  3. Let result be a new Record with all the internal slots given in the Internal Slot column in Table 6, as well as a [[Year]] slot.
  4. For each row of Table 6, except the header row, in table order, do
    1. Let property be the Property value of the current row.
    2. Let value be ? Get(temporalMonthDayLike, property).
    3. If value is undefined, then
      1. Throw a TypeError exception.
    4. Let value be ? ToInteger(value).
    5. Set result's internal slot whose name is the Internal Slot value of the current row to value.
  5. Set result.[[Year]] to the first leap year after the Unix epoch (1972).
  6. Return result.

9.4.10 TemporalMonthDayToString ( monthDay )

  1. Assert: Type(monthDay) is Object.
  2. Assert: monthDay has an [[InitializedTemporalMonthDay]] internal slot.
  3. Let month be monthDay.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  4. Let day be monthDay.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Return the string-concatenation of month, the code unit 0x002D (HYPHEN-MINUS), and day.

10 Temporal.TimeZone Objects

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

10.1 The Temporal.TimeZone Constructor

The Temporal.TimeZone constructor is the %Temporal.TimeZone% intrinsic object. When called as a constructor, it creates and initializes a new Temporal.TimeZone object.

The Temporal.TimeZone constructor is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified TimeZone behaviour must include a super call to the %Temporal.TimeZone% constructor to create and initialize subclass instances with the necessary internal slots.

10.1.1 Temporal.TimeZone ( identifier )

When the Temporal.TimeZone function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let identifier be ? ToString(identifier).
  3. If identifier does not satisfy the syntax of a TemporalTimeZoneIdentifier (see 14.22), then
    1. Throw a TypeError exception.
  4. Let sign, hour, minute, and name be the parts of identifier produced respectively by the TimeZoneUTCOffsetSign, TimeZoneUTCOffsetHour, TimeZoneUTCOffsetMinute and TimeZoneIANAName productions, or undefined if not present.
  5. If hour is not undefined, then
    1. Assert: sign is not undefined.
    2. Set hour to ! ToInteger(hour).
    3. If sign = "-", then
      1. Set hour to −1 × hour.
    4. If minute is not undefined, then
      1. Set minute to ! ToInteger(minute).
    5. Do something with the offset.
  6. If ! IsValidTimeZoneName(name) is false, then
    1. Throw a TypeError exception.
  7. Let canonical be ! CanonicalizeTimeZoneName(identifier).
  8. Return ? CreateTemporalTimeZone(canonical, NewTarget).

10.2 Properties of the Temporal.TimeZone Constructor

The value of the [[Prototype]] internal slot of the Temporal.TimeZone constructor is the intrinsic object %FunctionPrototype%.

The Temporal.TimeZone constructor has the following properties:

10.2.1 Temporal.TimeZone.prototype

The initial value of Temporal.TimeZone.prototype is %Temporal.TimeZone.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

10.2.2 get Temporal.TimeZone [ @@species ]

Temporal.TimeZone[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

10.2.3 Temporal.TimeZone.from ( item )

The from method takes one argument item. The following steps are taken:

  1. If Type(item) is Object, then
    1. Return item.
  2. Let string be ? ToString(item).
  3. Let result be ? ParseTemporalTimeZone(string).
  4. Let constructor be the this value.
  5. Return ? CreateTemporalTimeZoneFromStatic(constructor, result).

This function is the %Temporal.TimeZone.from intrinsic object.

10.3 Properties of the Temporal.TimeZone Prototype Object

The Temporal.TimeZone prototype object

  • is the intrinsic object %Temporal.TimeZone.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.TimeZone instance and does not have a [[InitializedTemporalTimeZone]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

10.3.1 Temporal.TimeZone.prototype.constructor

The initial value of Temporal.TimeZone.prototype.constructor is %Temporal.TimeZone%.

10.3.2 Temporal.TimeZone.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.TimeZone".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

10.3.3 get Temporal.TimeZone.prototype.name

Temporal.TimeZone.prototype.name is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let timeZone be the this value.
  2. Return ? TimeZoneToString(timeZone).

10.3.4 Temporal.TimeZone.prototype.getOffsetNanosecondsFor ( absolute )

The getOffsetNanosecondsFor method takes one argument absolute. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
  3. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  4. Let offset be ! ParseOffsetNanoseconds(timeZone.[[Identifier]]).
  5. If offset is not undefined, then
    1. Return offset.
  6. Let epochNs be absolute.[[Nanoseconds]].
  7. Check if this can be ? BalanceDateTime(1970, 1, 1, 0, 0, 0, 0, 0, epochNs).
  8. Let epochMs be RoundTowardsZero(epochNs / 1,000,000).
  9. Let mcs be ! NonNegativeModulo(RoundTowardsZero(epochNs / 1000), 1000).
  10. Let ns be ! NonNegativeModulo(epochNs, 1000).
  11. Let tm be ! ToLocalTime(epochMs, "gregory", timeZone.[[Identifier]]).
  12. Let ms be ! NonNegativeModulo(epochMs, 1000).
  13. Let result be ? BalanceDateTime(tm.[[Year]], tm.[[Month]], tm.[[Day]], tm.[[Hour]], tm.[[Minute]], tm.[[Second]], ms, mcs, ns).
  14. Let utc be ! GetEpochFromParts(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
  15. Return utcepochNs.

This function is the %Temporal.TimeZone.prototype.getOffsetNanosecondsFor% intrinsic object.

10.3.5 Temporal.TimeZone.prototype.getOffsetStringFor ( absolute )

The getOffsetStringFor method takes one argument absolute. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
  3. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  4. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, absolute).
  5. Return ? FormatTimeZoneOffsetString(offsetNanoseconds).

This function is the %Temporal.TimeZone.prototype.getOffsetStringFor% intrinsic object.

10.3.6 Temporal.TimeZone.prototype.getDateTimeFor ( absolute [ , calendarLike ] )

The getDateTimeFor method takes two arguments, absolute and calendarLike. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  3. If calendarLike is undefined, then
    1. Let calendar be ! GetDefaultCalendar().
  4. Else,
    1. Let calendar be ? ToTemporalCalendar(calendarLike).
  5. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, absolute).
  6. TODO: Let result be the moment absolute.[[Nanosecond]] nanoseconds from the epoch, in the UTC time zone.
  7. Set result to ? BalanceDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]] + offsetNanoseconds).
  8. TODO: pass calendar along.
  9. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

This function is the %Temporal.TimeZone.prototype.getDateTimeFor% intrinsic object.

10.3.7 Temporal.TimeZone.prototype.getAbsoluteFor ( dateTime [ , options ] )

The getAbsoluteFor method takes two arguments, dateTime and options. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
  3. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  4. Let disambiguation be ? ToTemporalDisambiguation(options).
  5. Let possibleAbsolutes be ? GetPossibleAbsolutesFor(timeZone, dateTime).
  6. Let n be possibleAbsolutes's length.
  7. If n = 1, then
    1. Return possibleAbsolutes[0].
  8. If n ≠ 0, then
    1. If disambiguation is "earlier" or "compatible", then
      1. Return possibleAbsolutes[0].
    2. If disambiguation is "later", then
      1. Return possibleAbsolutes[n − 1].
    3. If disambiguation is "reject", then
      1. Throw a RangeError exception.
  9. TODO - handle n=0 (skipped times like Spring DST).

This function is the %Temporal.TimeZone.prototype.getAbsoluteFor% intrinsic object.

10.3.8 Temporal.TimeZone.prototype.getPossibleAbsolutesFor ( dateTime )

The getPossibleAbsolutesFor method takes one argument dateTime. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimezone]]).
  3. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  4. TODO.

This function is the %Temporal.TimeZone.prototype.getPossibleAbsolutesFor% intrinsic object.

10.3.9 Temporal.TimeZone.prototype.getNextTransition ( startingPoint )

The getNextTransition method takes one argument startingPoint. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
  3. Perform ? RequireInternalSlot(startingPoint, [[InitializedTemporalAbsolute]]).
  4. TODO.

10.3.10 Temporal.TimeZone.prototype.getPreviousTransition ( startingPoint )

The getPreviousTransition method takes one argument startingPoint. The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
  3. Perform ? RequireInternalSlot(startingPoint, [[InitializedTemporalAbsolute]]).
  4. TODO.

10.3.11 Temporal.TimeZone.prototype.toString ( )

The following steps are taken:

  1. Let timeZone be the this value.
  2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
  3. Return timeZone.[[Identifier]].

This function is the %Temporal.TimeZone.prototype.toString% intrinsic object.

10.3.12 Temporal.TimeZone.prototype.toJSON ( )

The following steps are taken:

  1. Let timeZone be the this value.
  2. Return ? TimeZoneToString(timeZone).

10.4 Abstract operations

10.4.1 CreateTemporalTimeZoneFromStatic ( constructor, identifier )

  1. Assert: ! IsValidTimeZoneName(identifier) is true.
  2. If ! IsConstructor(constructor) is false, throw a TypeError exception.
  3. Let result be ? Construct(constructor, « identifier »).
  4. Perform ? RequireInternalSlot(result, [[InitializedTemporalTimeZone]]).
  5. Return result.

10.4.2 ParseTemporalTimeZone ( string )

  1. Assert: Type(string) is String.
  2. Let result be ? ParseTemporalTimeZoneString(string).
  3. Return result.[[TimeZoneName]].

10.4.3 CreateTemporalTimeZone ( identifier [ , newTarget ] )

  1. Assert: ! CanonicalizeTimeZoneName(identifier) is identifier.
  2. If newTarget is not given, set it to %Temporal.TimeZone%.
  3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.TimeZone.prototype%", « [[InitializedTemporalTimeZone]], [[Identifier]] »).
  4. Set object.[[Identifier]] to identifier.
  5. Return object.

10.4.4 FormatTimeZoneOffsetString ( offsetNanoseconds )

  1. Assert: offsetNanoseconds is an integer Number value.
  2. If offsetNanoseconds ≥ 0, let sign be "+"; otherwise, let sign be "-".
  3. Let offsetMinutes be floor(abs(offsetNanoseconds) / (60 × 109)).
  4. Let h be floor(offsetMinutes / 60), formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Let m be offsetMinutes modulo 60, formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  6. Return the string-concatenation of sign, h, the code unit 0x003A (COLON), and m.

10.4.5 ToTemporalTimeZone ( temporalTimeZoneLike )

  1. If Type(temporalTimeZoneLike) is Object, return temporalTimeZoneLike.
  2. Let identifier be ? ToString(temporalTimeZoneLike).
  3. Return ? TimeZoneFrom(identifier).

10.4.6 TimeZoneFrom ( identifier )

  1. Let from be ? Get(%Temporal.TimeZone%, "from").
  2. If from is undefined, set from to %Temporal.TimeZone.from%.
  3. Return ? Call(from, %Temporal.TimeZone%, « identifier »).

10.4.7 GetOffsetNanosecondsFor ( timeZone, absolute )

  1. Let getOffsetNanosecondsFor be ? Get(timeZone, "getOffsetNanosecondsFor").
  2. If getOffsetNanosecondsFor is undefined, set getOffsetNanosecondsFor to %Temporal.TimeZone.prototype.getOffsetNanosecondsFor%.
  3. Let offsetNanoseconds be ? Call(getOffsetNanosecondsFor, timeZone, « absolute »).
  4. If Type(offsetNanoseconds) is not Number, throw a TypeError exception.
  5. If ! IsInteger(offsetNanoseconds) is false or abs(offsetNanoseconds) > 86400 × 109, throw a RangeError exception.
  6. Return offsetNanoseconds.

10.4.8 GetOffsetStringFor ( timeZone, absolute )

  1. Let getOffsetStringFor be ? Get(timeZone, "getOffsetStringFor").
  2. If getOffsetStringFor is undefined, set getOffsetStringFor to %Temporal.TimeZone.prototype.getOffsetStringFor%.
  3. Return ? ToString(? Call(getOffsetStringFor, timeZone, « absolute »)).

10.4.9 GetTemporalDateTimeFor ( timeZone, absolute, calendar )

  1. Let getDateTimeFor be ? Get(timeZone, "getDateTimeFor").
  2. If getDateTimeFor is undefined, set getDateTimeFor to %Temporal.TimeZone.prototype.getDateTimeFor%.
  3. Let dateTime be ? Call(getDateTimeFor, timeZone, « absolute, calendar »).
  4. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  5. Return dateTime.

10.4.10 GetTemporalAbsoluteFor ( timeZone, dateTime, disambiguation )

  1. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
  2. Perform ! CreateDataPropertyOrThrow(options, "disambiguation", disambiguation).
  3. Let getAbsoluteFor be ? Get(timeZone, "getAbsoluteFor").
  4. If getAbsoluteFor is undefined, set getAbsoluteFor to %Temporal.TimeZone.prototype.getAbsoluteFor%.
  5. Let absolute be ? Call(getAbsoluteFor, timeZone, « dateTime »).
  6. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  7. Return absolute.

10.4.11 GetPossibleAbsolutesFor ( timeZone, dateTime )

  1. Let getPossibleAbsolutesFor be ? Get(timeZone, "getPossibleAbsolutesFor").
  2. Let possibleAbsolutes be ? Call(getPossibleAbsolutesFor, timeZone, « dateTime »).
  3. Let list be ? CreateListFromArrayLike(possibleAbsolutes).
  4. For each element absolute in list in List order, do
    1. Perform ? RequireInternalSlot(absolute, [[InitializedTemporalAbsolute]]).
  5. Return list.

10.4.12 TimeZoneToString ( timeZone )

  1. Let toString be ? Get(timeZone, "toString").
  2. If toString is undefined, set toString to %Temporal.TimeZone.prototype.toString%.
  3. Return be ? ToString(? Call(toString, timeZone, « »)).

10.4.13 ParseOffsetNanoseconds ( identifier )

  1. Assert: Type(identifier) is String.
  2. If identifier is not an offset string, return undefined.
  3. Let sign, hours, minutes be the result of parsing identifier.
  4. Return sign × (hours × 60 + minutes) × 60 × 1,000,000,000.

11 Temporal.Calendar Objects

A Temporal.Calendar object is an immutable Object representing a calendar.

11.1 Abstract Operations for Temporal.Calendar Objects

11.1.1 GetBuiltinCalendar ( id )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the GetBuiltinCalendar abstract operation as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the GetBuiltinCalendar abstract operation is used.

  1. If id is not "iso8601", throw a RangeError exception.
  2. Return ? Construct(%Temporal.ISO8601Calendar%, « »).

11.1.2 GetDefaultCalendar ( )

  1. Return ? GetBuiltinCalendar("iso8601").

11.1.3 CalendarToString ( calendar )

  1. Let toString be ? Get(calendar, "toString").
  2. If toString is undefined, set toString to %Temporal.Calendar.prototype.toString%.
  3. Return ? ToString(? Call(toString , calendar, « »)).

11.1.4 ToTemporalCalendar ( temporalCalendarLike )

  1. If Type(temporalCalendarLike) is Object, then
    1. Return temporalCalendarLike.
  2. Let identifier be ? ToString(temporalCalendarLike).
  3. Return ? CalendarFrom(identifier).

11.1.5 CalendarFrom ( identifier )

  1. Let from be ? Get(%Temporal.Calendar%, "from").
  2. If from is undefined, set from to %Temporal.Calendar.from%.
  3. Let calendar be ? Call(from, %Temporal.Calendar%, « identifier »).
  4. If Type(calendar) is not Object, then
    1. Throw a TypeError exception.
  5. Return calendar.

11.2 The Temporal.Calendar Constructor

The Temporal.Calendar constructor:

  • is the intrinsic object %Temporal.Calendar%.
  • creates and initializes a new Temporal.Calendar object when called as a constructor.
  • is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.Calendar behaviour must include a super call to the %Temporal.Calendar% constructor to create and initialize subclass instances with the necessary internal slots.
  • has a "length" property whose value is 1.

11.2.1 Temporal.Calendar ( id )

When the Temporal.Calendar function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let calendar be ? OrdinaryCreateFromConstructor(NewTarget, "%Temporal.Calendar.prototype%", « [[InitializedTemporalCalendar]], [[Identifier]] »).
  3. Set calendar.[[Identifier]] to id.
  4. Return calendar.

11.3 Properties of the Temporal.Calendar Constructor

The Temporal.Calendar prototype:

  • has a [[Prototype]] internal slot whose value is %FunctionPrototype%.
  • has the following properties:

11.3.1 Temporal.Calendar.prototype

The initial value of Temporal.Calendar.prototype is %Temporal.Calendar.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

11.3.2 get Temporal.Calendar [ @@species ]

Temporal.Calendar[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

11.3.3 Temporal.Calendar.from ( item )

The from method takes one argument item. The following steps are taken:

  1. If Type(item) is Object, then
    1. Return item.
  2. Let stringIdent be ? ToString(item).
  3. Return ? GetBuiltinCalendar(stringIdent).

This function is the %Temporal.Calendar.from% intrinsic object.

11.4 Properties of the Temporal.Calendar Prototype Object

The Temporal.Calendar prototype object

  • is the intrinsic object %Temporal.Calendar.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.Calendar instance and does not have a [[InitializedTemporalCalendar]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

11.4.1 Temporal.Calendar.prototype.constructor

The initial value of Temporal.Calendar.prototype.constructor is %Temporal.Calendar%.

11.4.2 Temporal.Calendar.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.Calendar".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

11.4.3 get Temporal.Calendar.prototype.id

Temporal.Calendar.prototype.id is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let calendar be the this value.
  2. Return ? CalendarToString(calendar).

11.4.4 Temporal.Calendar.prototype.dateFromFields ( fields, options, constructor )

The dateFromFields method takes three arguments, fields, options, and constructor. The following steps are taken:

  1. Throw an Error exception.

11.4.5 Temporal.Calendar.prototype.yearMonthFromFields ( fields, options, constructor )

The yearMonthFromFields method takes three arguments, fields, options, and constructor. The following steps are taken:

  1. Throw an Error exception.

11.4.6 Temporal.Calendar.prototype.monthDayFromFields ( fields, options, constructor )

The monthDayFromFields method takes three arguments, fields, options, and constructor. The following steps are taken:

  1. Throw an Error exception.

11.4.7 Temporal.Calendar.prototype.datePlus ( date, duration, options, constructor )

The datePlus method takes four arguments, date, duration, options, and constructor. The following steps are taken:

  1. Throw an Error exception.

11.4.8 Temporal.Calendar.prototype.dateMinus ( date, duration, options, constructor )

The dateMinus method takes four arguments, date, duration, options, and constructor. The following steps are taken:

  1. Throw an Error exception.

11.4.9 Temporal.Calendar.prototype.dateDifference ( one, two, options )

The dateDifference method takes three arguments, one, two, and options. The following steps are taken:

  1. Throw an Error exception.

11.4.10 Temporal.Calendar.prototype.year ( date )

The year method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.11 Temporal.Calendar.prototype.month ( date )

The month method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.12 Temporal.Calendar.prototype.day ( date )

The day method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.13 Temporal.Calendar.prototype.era ( date )

The era method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.14 Temporal.Calendar.prototype.dayOfWeek ( date )

The dayOfWeek method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.15 Temporal.Calendar.prototype.dayOfYear ( date )

The dayOfYear method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.16 Temporal.Calendar.prototype.weekOfYear ( date )

The weekOfYear method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.17 Temporal.Calendar.prototype.daysInWeek ( date )

The daysInWeek method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.18 Temporal.Calendar.prototype.daysInMonth ( date )

The daysInMonth method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.19 Temporal.Calendar.prototype.daysInYear ( date )

The daysInYear method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.20 Temporal.Calendar.prototype.monthsInYear ( date )

The monthsInYear method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.21 Temporal.Calendar.prototype.isLeapYear ( date )

The isLeapYear method takes one argument date. The following steps are taken:

  1. Throw an Error exception.

11.4.22 Temporal.Calendar.prototype.toString ( )

The following steps are taken:

  1. Let calendar be the this value.
  2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
  3. Return calendar.[[Identifier]].

This function is the %Temporal.Calendar.prototype.toString% intrinsic object.

11.5 Properties of Temporal.Calendar Instances

Temporal.Calendar instances are ordinary objects that inherit properties from the %Temporal.Calendar.prototype%. Temporal.Calendar instances also have a [[Identifier]] internal slot. The value of this internal slot is a string.

12 Temporal.ISO8601Calendar Objects

A Temporal.ISO8601Calendar object is an immutable Object representing an ISO 8601 calendar.

12.1 The Temporal.ISO8601Calendar Constructor

The Temporal.ISO8601Calendar constructor:

  • is the intrinsic object %Temporal.ISO8601Calendar%.
  • creates and initializes a new Temporal.ISO8601Calendar object when called as a constructor.
  • is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.ISO8601Calendar behaviour must include a super call to the %Temporal.ISO8601Calendar% constructor to create and initialize subclass instances with the necessary internal slots.
  • has a "length" property whose value is 1.

12.1.1 Temporal.ISO8601Calendar ( id )

When the Temporal.ISO8601Calendar function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let calendar be ? OrdinaryCreateFromConstructor(NewTarget, "%Temporal.ISO8601Calendar.prototype%", « [[InitializedTemporalISO8601Calendar]], [[InitializedTemporalCalendar]], [[Identifier]] »).
  3. Set calendar.[[Identifier]] to id.
  4. Return calendar.

12.2 Properties of the Temporal.ISO8601Calendar Constructor

The Temporal.ISO8601Calendar prototype:

  • has a [[Prototype]] internal slot whose value is %Temporal.Calendar.prototype%.
  • has the following properties:

12.2.1 Temporal.ISO8601Calendar.prototype

The initial value of Temporal.ISO8601Calendar.prototype is %Temporal.ISO8601Calendar.prototype%.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

12.2.2 get Temporal.ISO8601Calendar [ @@species ]

Temporal.ISO8601Calendar[@@species] is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Return the this value.

The value of the "name" property of this function is "get [Symbol.species]".

12.3 Properties of the Temporal.ISO8601Calendar Prototype Object

The Temporal.ISO8601Calendar prototype object

  • is the intrinsic object %Temporal.ISO8601Calendar.prototype%.
  • is itself an ordinary object.
  • is not a Temporal.ISO8601Calendar instance and does not have a [[InitializedTemporalCalendar]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Temporal.Calendar.prototype%.

12.3.1 Temporal.ISO8601Calendar.prototype.constructor

The initial value of Temporal.ISO8601Calendar.prototype.constructor is %Temporal.ISO8601Calendar%.

12.3.2 Temporal.ISO8601Calendar.prototype[ @@toStringTag ]

The initial value of the @@toStringTag property is the string value "Temporal.ISO8601Calendar".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

12.3.3 Temporal.ISO8601Calendar.prototype.dateFromFields ( fields, options, constructor )

The dateFromFields method takes three arguments, fields, options, and constructor. The following steps are taken:

  1. TODO.

12.3.4 Temporal.ISO8601Calendar.prototype.yearMonthFromFields ( fields, options, constructor )

The yearMonthFromFields method takes three arguments, fields, options, and constructor. The following steps are taken:

  1. TODO.

12.3.5 Temporal.ISO8601Calendar.prototype.monthDayFromFields ( fields, options, constructor )

The monthDayFromFields method takes three arguments, fields, options, and constructor. The following steps are taken:

  1. TODO.

12.3.6 Temporal.ISO8601Calendar.prototype.datePlus ( date, duration, options, constructor )

The datePlus method takes four arguments, date, duration, options, and constructor. The following steps are taken:

  1. TODO.

12.3.7 Temporal.ISO8601Calendar.prototype.dateMinus ( date, duration, options, constructor )

The dateMinus method takes four arguments, date, duration, options, and constructor. The following steps are taken:

  1. TODO.

12.3.8 Temporal.ISO8601Calendar.prototype.dateDifference ( one, two, options )

The dateDifference method takes three arguments, one, two, and options. The following steps are taken:

  1. TODO.

12.3.9 Temporal.ISO8601Calendar.prototype.year ( dateOrDateTime )

The year method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return dateOrDateTime.[[ISOYear]].

12.3.10 Temporal.ISO8601Calendar.prototype.month ( dateOrDateTime )

The month method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return dateOrDateTime.[[ISOMonth]].

12.3.11 Temporal.ISO8601Calendar.prototype.day ( dateOrDateTime )

The day method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return dateOrDateTime.[[ISODay]].

12.3.12 Temporal.ISO8601Calendar.prototype.era ( dateOrDateTime )

The era method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return undefined.

12.3.13 Temporal.ISO8601Calendar.prototype.dayOfWeek ( dateOrDateTime )

The dayOfWeek method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return ! ToDayOfWeek(dateOrDateTime.[[ISOYear]], dateOrDateTime.[[ISOMonth]], dateOrDateTime.[[ISODay]]).

12.3.14 Temporal.ISO8601Calendar.prototype.dayOfYear ( dateOrDateTime )

The dayOfYear method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return ! ToDayOfYear(dateOrDateTime.[[ISOYear]], dateOrDateTime.[[ISOMonth]], dateOrDateTime.[[ISODay]]).

12.3.15 Temporal.ISO8601Calendar.prototype.weekOfYear ( dateOrDateTime )

The weekOfYear method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return ! ToWeekOfYear(dateOrDateTime.[[ISOYear]], dateOrDateTime.[[ISOMonth]], dateOrDateTime.[[ISODay]]).

12.3.16 Temporal.ISO8601Calendar.prototype.daysInWeek ( dateOrDateTime )

The daysInWeek method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return 7.

12.3.17 Temporal.ISO8601Calendar.prototype.daysInMonth ( dateOrDateTime )

The daysInMonth method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return ! DaysInMonth(dateOrDateTime.[[ISOYear]], dateOrDateTime.[[ISOMonth]]).

12.3.18 Temporal.ISO8601Calendar.prototype.daysInYear ( dateOrDateTime )

The daysInYear method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return ! DaysInYear(dateOrDateTime.[[ISOYear]]).

12.3.19 Temporal.ISO8601Calendar.prototype.monthsInYear ( dateOrDateTime )

The monthsInYear method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return 12.

12.3.20 Temporal.ISO8601Calendar.prototype.isLeapYear ( dateOrDateTime )

The isLeapYear method takes one argument dateOrDateTime. The following steps are taken:

  1. Perform ? RequireOneOfInternalSlots(dateOrDateTime, « [[InitializedTemporalDate]], [[InitializedTemporalDateTime]] »).
  2. Return ! IsLeapYear(dateOrDateTime.[[ISOYear]]).

12.4 Properties of Temporal.ISO8601Calendar Instances

Temporal.ISO8601Calendar instances are ordinary objects that inherit properties from the %Temporal.ISO8601Calendar.prototype%. Temporal.ISO8601Calendar instances also have a [[Identifier]] internal slot. The value of this internal slot is a string.

12.5 Abstract Operations for Temporal.Date Objects

12.5.1 IsLeapYear ( year )

  1. Assert: year is an integer.
  2. If year modulo 4 ≠ 0, return false.
  3. If year modulo 400 = 0, return true.
  4. If year modulo 100 = 0, return false.
  5. Return true.

12.5.2 DaysInYear ( year )

  1. Assert: year is an integer.
  2. If ! IsLeapYear(year) is true, then
    1. Return 366.
  3. Return 365.

12.5.3 DaysInMonth ( year, month )

  1. Assert: month is an integer, month ≥ 1, and month ≤ 12.
  2. If month is 1, 3, 5, 7, 8, 10, or 12, return 31.
  3. If month is 4, 6, 9, or 11, return 30.
  4. If ! IsLeapYear(year) is true, return 29.
  5. Return 28.

12.5.4 ToDayOfWeek ( year, month, day )

  1. Let date be the date given by year, month, and day.
  2. Return date's day of the week according to ISO-8601.
Note
Monday is 1 and Sunday is 7.

12.5.5 ToDayOfYear ( year, month, day )

  1. Let date be the date given by year, month, and day.
  2. Return date's ordinal date in the year according to ISO-8601.

12.5.6 ToWeekOfYear ( year, month, day )

  1. Let date be the date given by year, month, and day.
  2. Return date's week number according to ISO-8601.
Note
Beware that dates at the beginning of a year may be part of a week from the preceding year, and dates at the end of a year may be part of a week at the beginning of the next year, as the first week of any year is defined as the week that contains the first Thursday of the year.

13 Integration with the Intl.DateTimeFormat interface

13.1 Abstract Operations For DateTimeFormat Objects

Table 7: Components of date and time formats
Internal Slot Property Values
[[Weekday]] "weekday" "narrow", "short", "long"
[[Era]] "era" "narrow", "short", "long"
[[Year]] "year" "2-digit", "numeric"
[[Month]] "month" "2-digit", "numeric", "narrow", "short", "long"
[[Day]] "day" "2-digit", "numeric"
[[Hour]] "hour" "2-digit", "numeric"
[[Minute]] "minute" "2-digit", "numeric"
[[Second]] "second" "2-digit", "numeric"
[[TimeZoneName]] "timeZoneName" "short", "long"

13.1.1 InitializeDateTimeFormat ( dateTimeFormat, locales, options )

The abstract operation InitializeDateTimeFormat accepts the arguments dateTimeFormat (which must be an object), locales, and options. It initializes dateTimeFormat as a DateTimeFormat object. This abstract operation functions as follows:

The following algorithm refers to the type nonterminal from UTS 35's Unicode Locale Identifier grammar.

  1. Let requestedLocales be ? CanonicalizeLocaleList(locales).
  2. Let options be ? ToDateTimeOptions(options, "any", "date").
  3. Let opt be a new Record.
  4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
  5. Set opt.[[localeMatcher]] to matcher.
  6. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
  7. If calendar is not undefined, then
    1. If calendar does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
  8. Set opt.[[ca]] to calendar.
  9. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
  10. If numberingSystem is not undefined, then
    1. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
  11. Set opt.[[nu]] to numberingSystem.
  12. Let hour12 be ? GetOption(options, "hour12", "boolean", undefined, undefined).
  13. Let hourCycle be ? GetOption(options, "hourCycle", "string", « "h11", "h12", "h23", "h24" », undefined).
  14. If hour12 is not undefined, then
    1. Let hourCycle be null.
  15. Set opt.[[hc]] to hourCycle.
  16. Let localeData be %DateTimeFormat%.[[LocaleData]].
  17. Let r be ResolveLocale( %DateTimeFormat%.[[AvailableLocales]], requestedLocales, opt, %DateTimeFormat%.[[RelevantExtensionKeys]], localeData).
  18. Set dateTimeFormat.[[Locale]] to r.[[locale]].
  19. Let calendar be r.[[ca]].
  20. Set dateTimeFormat.[[Calendar]] to calendar.
  21. Set dateTimeFormat.[[HourCycle]] to r.[[hc]].
  22. Let dataLocale be r.[[dataLocale]].
  23. Let dataLocaleData be localeData.[[<dataLocale>]].
  24. Let hcDefault be dataLocaleData.[[hourCycle]].
  25. Let hc be r.[[hc]].
  26. If hc is null, then
    1. Set hc to hcDefault.
  27. If hour12 is not undefined, then
    1. If hour12 is true, then
      1. If hcDefault is "h11" or "h23", then
        1. Set hc to "h11".
      2. Else,
        1. Set hc to "h12".
    2. Else,
      1. Assert: hour12 is false.
      2. If hcDefault is "h11" or "h23", then
        1. Set hc to "h23".
      3. Else,
        1. Set hc to "h24".
  28. Set dateTimeFormat.[[NumberingSystem]] to r.[[nu]].
  29. Let dataLocale be r.[[dataLocale]].
  30. Let timeZone be ? Get(options, "timeZone").
  31. If timeZone is undefined, then
    1. Let timeZone be DefaultTimeZone().
  32. Else,
    1. Let timeZone be ? ToString(timeZone).
    2. If the result of IsValidTimeZoneName(timeZone) is false, then
      1. Throw a RangeError exception.
    3. Let timeZone be CanonicalizeTimeZoneName(timeZone).
  33. Set dateTimeFormat.[[TimeZone]] to timeZone.
  34. Let opt be a new Record.
  35. For each row of Table 7, except the header row, in table order, do
    1. Let prop be the name given in the Property column of the row.
    2. Let value be ? GetOption(options, prop, "string", « the strings given in the Values column of the row », undefined).
    3. Set opt.[[<prop>]] to value.
  36. Let dataLocaleData be localeData.[[<dataLocale>]].
  37. Let formats be dataLocaleData.[[formats]].[[<calendar>]].
  38. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit").
  39. If matcher is "basic", then
    1. Let bestFormat be BasicFormatMatcher(opt, formats).
  40. Else,
    1. Let bestFormat be BestFitFormatMatcher(opt, formats).
  41. For each row in Table 7, except the header row, in table order, do
    1. Let prop be the name given in the Property column of the row.
    2. Let p be bestFormat.[[<prop>]].
    3. If p not undefined, then
      1. Set dateTimeFormat's internal slot whose name is the Internal Slot column of the row to p.
  42. If dateTimeFormat.[[Hour]] is undefined, then
    1. Set dateTimeFormat.[[HourCycle]] to undefined.
    2. Let pattern be bestFormat.[[pattern]].
  43. Else,
    1. Let hcDefault be dataLocaleData.[[hourCycle]].
    2. Let hc be dateTimeFormat.[[HourCycle]].
    3. If hc is null, then
      1. Set hc to hcDefault.
    4. If hour12 is not undefined, then
      1. If hour12 is true, then
        1. If hcDefault is "h11" or "h23", then
          1. Set hc to "h11".
        2. Else,
          1. Set hc to "h12".
      2. Else,
        1. Assert: hour12 is false.
        2. If hcDefault is "h11" or "h23", then
          1. Set hc to "h23".
        3. Else,
          1. Set hc to "h24".
    5. Set dateTimeFormat.[[HourCycle]] to hc.
    6. If dateTimeformat.[[HourCycle]] is "h11" or "h12", then
      1. Let pattern be bestFormat.[[pattern12]].
    7. Else,
      1. Let pattern be bestFormat.[[pattern]].
  44. Else,
    1. Set dateTimeFormat.[[HourCycle]] to undefined.
    2. Let pattern be bestFormat.[[pattern]].
  45. Let expandedOptions be a copy of opt.
  46. Let needDefaults be true.
  47. For each field of « "weekday", "year", "month", "day", "hour", "minute", "second" », do
    1. If expandedOptions.[[<field>]] is not undefined, then
      1. Set needDefaults to false.
  48. If needDefaults is true, then
    1. For each field of « "year", "month", "day", "hour", "minute", "second" », do
      1. Set expandedOptions.[[<field>]] to "numeric".
  49. Set dateTimeFormat.[[Pattern]] to patternGetDateTimeFormatPattern(expandedOptions, formats, hc).
  50. For each row in Table 8, except the header row, in table order, do
    1. Let limitedOptions be a new Record.
    2. Let needDefaults be true.
    3. Let fields be the list of fields in the Supported fields column of the row.
    4. For each field field of opt, do
      1. If field is in fields, then
        1. Set needDefaults to false.
        2. Set limitedOptions.[[<field>]] to opt.[[<field>]].
    5. If needDefaults is true, then
      1. Let defaultFields be the list of fields in the Supported fields column of the row.
      2. For each field of defaultFields, do
        1. Set limitedOptions.[[<field>]] to something.
    6. Let bestFormat be GetDateTimeFormatPattern(limitedOptions, formats, hc).
    7. If bestFormat does not have any fields that are in fields, then
      1. Set bestFormat to null.
    8. Set dateTimeFormat's internal slot whose name is the Pattern column of the row to bestFormat.
  51. Return dateTimeFormat.
Table 8: Supported fields for temporal patterns
Pattern Supported fields Default fields
[[TemporalDatePattern]] [[weekday]], [[era]], [[year]], [[month]], [[day]] [[year]], [[month]], [[day]]
[[TemporalYearMonthPattern]] [[era]], [[year]], [[month]] [[year]], [[month]]
[[TemporalMonthDayPattern]] [[month]], [[day]] [[month]], [[day]]
[[TemporalTimePattern]] [[hour]], [[minute]], [[second]], [[dayPeriod]], [[fractionalSecondDigits]] [[hour]], [[minute]], [[second]]
[[TemporalDateTimePattern]] [[weekday]], [[era]], [[year]], [[month]], [[day]], [[hour]], [[minute]], [[second]], [[dayPeriod]], [[fractionalSecondDigits]] [[year]], [[month]], [[day]], [[hour]], [[minute]], [[second]]
[[TemporalAbsolutePattern]] [[weekday]], [[era]], [[year]], [[month]], [[day]], [[hour]], [[minute]], [[second]], [[dayPeriod]], [[fractionalSecondDigits]] [[year]], [[month]], [[day]], [[hour]], [[minute]], [[second]]

13.1.2 DateTime Format Functions

A DateTime format function is an anonymous built-in function that has a [[DateTimeFormat]] internal slot.

When a DateTime format function F is called with optional argument date, the following steps are taken:

  1. Let dtf be F.[[DateTimeFormat]].
  2. Assert: Type(dtf) is Object and dtf has an [[InitializedDateTimeFormat]] internal slot.
  3. If date is not provided or is undefined, then
    1. Let x be Call(%Date.now%, undefined).
  4. Else,
    1. Let x be ? ToNumber(date).
  5. Return ? FormatDateTime(dtf, xdate).

The "length" property of a DateTime format function is 1.

13.1.3 PartitionDateTimePattern ( dateTimeFormat, xdate )

The PartitionDateTimePattern abstract operation is called with arguments dateTimeFormat (which must be an object initialized as a DateTimeFormat) and xdate (which must be a Numberan ECMAScript value), interprets x as a time value as specified in ES2021, 20.4.1.1, and creates the corresponding parts according to the effective locale and the formatting options of dateTimeFormat. The following steps are taken:

  1. If IsTemporalObject(date) is true, then
    1. Let x be date.
    2. TODO: era, dayPeriod, fractionalSecondDigits.
    3. If date has an [[InitializedTemporalDate]] internal slot, then
      1. Let pattern be dateTimeFormat.[[TemporalDatePattern]].
      2. Let tm be { [[weekday]]: ToDayOfWeek(date.[[Year]], date.[[Month]], date.[[Day]]), [[year]]: date.[[Year]], [[month]]: date.[[Month]], [[day]]: date.[[Day]] }.
    4. If date has an [[InitializedTemporalYearMonth]] internal slot, then
      1. Let pattern be dateTimeFormat.[[TemporalYearMonthPattern]].
      2. Let tm be { [[year]]: date.[[Year]], [[month]]: date.[[Month]] }.
    5. If date has an [[InitializedTemporalMonthDay]] internal slot, then
      1. Let pattern be dateTimeFormat.[[TemporalMonthDayPattern]].
      2. Let tm be { [[month]]: date.[[Month]], [[day]]: date.[[Day]] }.
    6. If date has an [[InitializedTemporalTime]] internal slot, then
      1. Let pattern be dateTimeFormat.[[TemporalTimePattern]].
      2. Let tm be { [[hour]]: date.[[Hour]], [[minute]]: date.[[Minute]], [[second]]: date.[[Second]] }.
    7. If date has an [[InitializedTemporalDateTime]] or an [[InitializedTemporalAbsolute]] internal slot, then
      1. Let pattern be dateTimeFormat.[[TemporalDateTimePattern]].
      2. Let tm be { [[weekday]]: ToDayOfWeek(date.[[Year]], date.[[Month]], date.[[Day]]), [[year]]: date.[[Year]], [[month]]: date.[[Month]], [[day]]: date.[[Day]], [[hour]]: date.[[Hour]], [[minute]]: date.[[Minute]], [[second]]: date.[[Second]] }.
    8. If pattern is null, throw a TypeError exception.
  2. Else,
    1. Let pattern be dateTimeFormat.[[Pattern]].
    2. If date is undefined, then
      1. Let x be Call(%Date.now%, undefined).
    3. Else,
      1. Let x be ? ToNumber(date).
    4. Let x be TimeClip(x).
    5. If x is NaN, throw a RangeError exception.
    6. Let tm be ToLocalTime(x, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]).
  3. Let locale be dateTimeFormat.[[Locale]].
  4. Let nfOptions be ObjectCreate(null).
  5. Perform ! CreateDataPropertyOrThrow(nfOptions, "useGrouping", false).
  6. Let nf be ? Construct(%NumberFormat%, « locale, nfOptions »).
  7. Let nf2Options be ObjectCreate(null).
  8. Perform ! CreateDataPropertyOrThrow(nf2Options, "minimumIntegerDigits", 2).
  9. Perform ! CreateDataPropertyOrThrow(nf2Options, "useGrouping", false).
  10. Let nf2 be ? Construct(%NumberFormat%, « locale, nf2Options »).
  11. Let tm be ToLocalTime(x, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]).
  12. Let result be a new empty List.
  13. Let patternParts be PartitionPattern(dateTimeFormat.[[Pattern]]pattern).
  14. For each element patternPart of patternParts, in List order, do
    1. Let p be patternPart.[[Type]].
    2. If p is "literal", then
      1. Append a new Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] } as the last element of the list result.
    3. Else if p matches a Property column of the row in Table 7, then
      1. Let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching rowpattern.[[<p>]].
      2. Let v be the value of tm's field whose name is the Internal Slot column of the matching row.
      3. If p is "year" and v ≤ 0, let v be 1 - v.
      4. If p is "month", increase v by 1.
      5. If p is "hour" and dateTimeFormat.[[HourCycle]]pattern.[[hourCycle]] is "h11" or "h12", then
        1. Let v be v modulo 12.
        2. If v is 0 and dateTimeFormat.[[HourCycle]]pattern.[[hourCycle]] is "h12", let v be 12.
      6. If p is "hour" and dateTimeFormat.[[HourCycle]]pattern.[[hourCycle]] is "h24", then
        1. If v is 0, let v be 24.
      7. If f is "numeric", then
        1. Let fv be FormatNumeric(nf, v).
      8. Else if f is "2-digit", then
        1. Let fv be FormatNumeric(nf2, v).
        2. If the "length" property of fv is greater than 2, let fv be the substring of fv containing the last two characters.
      9. Else if f is "narrow", "short", or "long", then let fv be a String value representing f in the desired form; the String value depends upon the implementation and the effective locale and calendar of dateTimeFormat. If p is "month", then the String value may also depend on whether dateTimeFormat has a [[Day]]pattern has a [[day]] internal slot. If p is "timeZoneName", then the String value may also depend on the value of the [[InDST]] field of tm. If p is "era", then the String value may also depend on whether dateTimeFormat has a [[Era]]pattern has a [[era]] internal slot and if the implementation does not have a localized representation of f, then use f itself.
      10. Append a new Record { [[Type]]: p, [[Value]]: fv } as the last element of the list result.
    4. Else if p is equal to "ampm", then
      1. Let v be tm.[[Hour]].
      2. If v is greater than 11, then
        1. Let fv be an implementation and locale dependent String value representing "post meridiem".
      3. Else,
        1. Let fv be an implementation and locale dependent String value representing "ante meridiem".
      4. Append a new Record { [[Type]]: "dayPeriod", [[Value]]: fv } as the last element of the list result.
    5. Else if p is equal to "relatedYear", then
      1. Let v be tm.[[RelatedYear]].
      2. Let fv be FormatNumeric(nf, v).
      3. Append a new Record { [[Type]]: "relatedYear", [[Value]]: fv } as the last element of the list result.
    6. Else if p is equal to "yearName", then
      1. Let v be tm.[[YearName]].
      2. Append a new Record { [[Type]]: "yearName", [[Value]]: v } as the last element of the list result.
    7. Else,
      1. Let unknown be an implementation-, locale-, and numbering system-dependent String based on xtm and p.
      2. Append a new Record { [[Type]]: "unknown", [[Value]]: unknown } as the last element of result.
  15. Return result.
Note 1
It is recommended that implementations use the locale and calendar dependent strings provided by the Common Locale Data Repository (available at http://cldr.unicode.org), and use CLDR "abbreviated" strings for DateTimeFormat "short" strings, and CLDR "wide" strings for DateTimeFormat "long" strings.
Note 2
It is recommended that implementations use the time zone information of the IANA Time Zone Database.

13.1.4 FormatDateTime ( dateTimeFormat, x )

The FormatDateTime abstract operation is called with arguments dateTimeFormat (which must be an object initialized as a DateTimeFormat) and x (which must be a Numberan ECMAScript value), and performs the following steps:

  1. Let parts be ? PartitionDateTimePattern(dateTimeFormat, x).
  2. Let result be the empty String.
  3. For each Record part in parts, do
    1. Set result to the string-concatenation of result and part.[[Value]].
  4. Return result.

13.1.5 FormatDateTimeToParts ( dateTimeFormat, x )

The FormatDateTimeToParts abstract operation is called with arguments dateTimeFormat (which must be an object initialized as a DateTimeFormat) and x (which must be a Numberan ECMAScript value), and performs the following steps:

  1. Let parts be ? PartitionDateTimePattern(dateTimeFormat, x).
  2. Let result be ArrayCreate(0).
  3. Let n be 0.
  4. For each Record part in parts, do
    1. Let O be ObjectCreate(%Object.prototype%).
    2. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
    3. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
    4. Perform ! CreateDataProperty(result, ! ToString(n), O).
    5. Increment n by 1.
  5. Return result.

13.1.6 IsTemporalObject ( value )

The IsTemporalObject abstract operation is called with argument value, and performs the following steps:

  1. If Type(value) is not Object, then
    1. Return false.
  2. If value does not have an [[InitializedTemporalDate]], [[InitializedTemporalTime]], [[InitializedTemporalDateTime]], [[InitializedTemporalYearMonth]], [[InitializedTemporalMonthDay]], or [[InitializedTemporalAbsolute]] internal slot, then
    1. Return false.
  3. Return true.

13.1.7 GetDateTimeFormatPattern ( opt, formats, hc )

The abstract operation GetDateTimeFormatPattern accepts the arguments opt (which must be a record), formats (a List of records), and hc (one of "h11", "h12", "h23", and "h24"). It returns one of the records from formats. This abstract operation functions as follows:

  1. If matcher is "basic", then
    1. Let bestFormat be BasicFormatMatcher(opt, formats).
  2. Else,
    1. Let bestFormat be BestFitFormatMatcher(opt, formats).
  3. If bestFormat.[[hour]] is not undefined, then
    1. If hc is "h11" or "h12", then
      1. Set bestFormat.[[pattern]] to bestFormat.[[pattern12]].
    2. Remove the [[pattern12]] field from bestFormat.
    3. Set bestFormat.[[hourCycle]] to hc.
  4. Else,
    1. Set bestFormat.[[hourCycle]] to undefined.
  5. Return bestFormat.

13.2 Properties of the Intl.DateTimeFormat Prototype Object

13.2.1 Intl.DateTimeFormat.prototype.formatToParts ( date )

When the formatToParts method is called with an argument date, the following steps are taken:

  1. Let dtf be the this value.
  2. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
  3. If date is undefined, then
    1. Let x be Call(%Date.now%, undefined).
  4. Else,
    1. Let x be ? ToNumber(date).
  5. Return ? FormatDateTimeToParts(dtf, xdate).

13.2.2 Intl.DateTimeFormat.prototype.resolvedOptions ( )

This function provides access to the locale and formatting options computed during initialization of the object.

  1. Let dtf be the this value.
  2. If Type(dtf) is not Object, throw a TypeError exception.
  3. Let dtf be ? UnwrapDateTimeFormat(dtf).
  4. Let options be ! ObjectCreate(%Object.prototype%).
  5. For each row of Table 9, except the header row, in table order, do
    1. Let p be the Property value of the current row.
    2. If p is "hour12", then
      1. Let hc be dtf.[[HourCycle]][[Pattern]].[[hourCycle]].
      2. If hc is "h11" or "h12", let v be true.
      3. Else if, hc is "h23" or "h24", let v be false.
      4. Else, let v be undefined.
    3. Else,
      1. If the Location value of the current row is object, then
        1. Let v be the value of dtf's internal slot whose name is the Internal Slot value of the current row.
      2. Else,
        1. Assert: the Location value of the current row is pattern.
        2. Let v be the value of dtf.[[Pattern]]'s internal slot whose name is the Internal Slot value of the current row.
    4. If v is not undefined, then
      1. Perform ! CreateDataPropertyOrThrow(options, p, v).
  6. Return options.
Table 9: Resolved Options of DateTimeFormat Instances
Internal Slot Property Location
[[Locale]] "locale" object
[[Calendar]] "calendar" object
[[NumberingSystem]] "numberingSystem" object
[[TimeZone]] "timeZone" object
[[HourCycle]][[hourCycle]] "hourCycle" pattern
"hour12"
[[Weekday]][[weekday]] "weekday" pattern
[[Era]][[era]] "era" pattern
[[Year]][[year]] "year" pattern
[[Month]][[month]] "month" pattern
[[Day]][[day]] "day" pattern
[[Hour]][[hour]] "hour" pattern
[[Minute]][[minute]] "minute" pattern
[[Second]][[second]] "second" pattern
[[TimeZoneName]][[timeZoneName]] "timeZoneName" pattern

For web compatibility reasons, if the property "hourCycle" is set, the "hour12" property should be set to true when "hourCycle" is "h11" or "h12", or to false when "hourCycle" is "h23" or "h24".

Note 1
In this version of the ECMAScript 2021 Internationalization API, the "timeZone" property will be the name of the default time zone if no "timeZone" property was provided in the options object provided to the Intl.DateTimeFormat constructor. The first edition left the "timeZone" property undefined in this case.
Note 2
For compatibility with versions prior to the fifth edition, the "hour12" property is set in addition to the "hourCycle" property.

13.3 Properties of Intl.DateTimeFormat Instances

Intl.DateTimeFormat instances are ordinary objects that inherit properties from %DateTimeFormat.prototype%.

Intl.DateTimeFormat instances have an [[InitializedDateTimeFormat]] internal slot.

Intl.DateTimeFormat instances also have several internal slots that are computed by the constructor:

  • [[Locale]] is a String value with the language tag of the locale whose localization is used for formatting.
  • [[Calendar]] is a String value with the "type" given in Unicode Technical Standard 35 for the calendar used for formatting.
  • [[NumberingSystem]] is a String value with the "type" given in Unicode Technical Standard 35 for the numbering system used for formatting.
  • [[TimeZone]] is a String value with the IANA time zone name of the time zone used for formatting.
  • [[Weekday]], [[Era]], [[Year]], [[Month]], [[Day]], [[Hour]], [[Minute]], [[Second]], [[TimeZoneName]] are each either undefined, indicating that the component is not used for formatting, or one of the String values given in Table 7, indicating how the component should be presented in the formatted output.
  • [[HourCycle]] is a String value indicating whether the 12-hour format ("h11", "h12") or the 24-hour format ("h23", "h24") should be used. "h11" and "h23" start with hour 0 and go up to 11 and 23 respectively. "h12" and "h24" start with hour 1 and go up to 12 and 24. [[HourCycle]] is only used when [[Hour]] is not undefined.
  • [[Pattern]], [[CivilDatePattern]], … are is a String valuerecords containing at least a [[pattern]] field as described in Internal slots.

Finally, Intl.DateTimeFormat instances have a [[BoundFormat]] internal slot that caches the function returned by the format accessor (get Intl.DateTimeFormat.prototype.format).

14 Abstract operations

14.1 NormalizeOptionsObject ( options )

The abstract operation NormalizeOptionsObject massages options into an Object to be subsequently passed to GetOption. It throws a TypeError if options is not undefined and not an Object.

  1. If options is undefined, then
    1. Return ! ObjectCreate(null).
  2. If Type(options) is Object, then
    1. Return options.
  3. Throw a TypeError exception.

14.2 GetOption ( options, property, type, values, fallback )

The abstract operation GetOption extracts the value of the property named property from the provided options object, converts it to the required type, checks whether it is one of a List of allowed values, and fills in a fallback value if necessary. If values is undefined, there is no fixed set of values and any is permitted.

  1. Assert: Type(options) is Object.
  2. Let value be ? Get(options, property).
  3. If value is undefined, return fallback.
  4. Assert: type is "boolean" or "string".
  5. If type is "boolean", then
    1. Let value be ! ToBoolean(value).
  6. If type is "string", then
    1. Let value be ? ToString(value).
  7. If values is not undefined and values does not contain an element equal to value, throw a RangeError exception.
  8. Return value.

14.3 RequireOneOfInternalSlots ( value, internalSlots )

The abstract operation RequireOneOfInternalSlots takes arguments value and internalSlots. It throws an exception unless value is an Object and has one of the given internal slots. It performs the following steps when called:

  1. If Type(value) is not Object, throw a TypeError exception.
  2. For each element slot of internalSlots, do
    1. If O has a slot internal slot, return.
  3. Throw a TypeError exception.

14.4 DefaultNumberOption ( value, minimum, maximum, fallback )

The abstract operation DefaultNumberOption converts value to a Number value, checks whether it is in the allowed range, and fills in a fallback value if necessary.

  1. If value is undefined, return fallback.
  2. Let value be ? ToNumber(value).
  3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
  4. Return floor(value).

14.5 GetNumberOption ( options, property, minimum, maximum, fallback )

The abstract operation GetNumberOption extracts the value of the property named property from the provided options object, converts it to a Number value, checks whether it is in the allowed range, and fills in a fallback value if necessary.

  1. Assert: Type(options) is Object.
  2. Let value be ? Get(options, property).
  3. Return ? DefaultNumberOption(value, minimum, maximum, fallback).

14.6 ToTemporalDurationOverflow ( options )

  1. Set options to ? NormalizeOptionsObject(options).
  2. Return ? GetOption(options, "overflow", « "constrain", "balance" », "constrain").

14.7 ToTemporalOverflow ( options )

  1. Set options to ? NormalizeOptionsObject(options).
  2. Return ? GetOption(options, "overflow", « "constrain", "reject" », "constrain").

14.8 ToTemporalDisambiguation ( options )

  1. Set options to ? NormalizeOptionsObject(options).
  2. Return ? GetOption(options, "disambiguation", "string", « "compatible", "earlier", "later", "reject" », "compatible").

14.9 ToTemporalRoundingMode ( options )

  1. Set options to ? NormalizeOptionsObject(options).
  2. Return ? GetOption(options, "roundingMode", "string", « "ceil", "floor", "trunc", "nearest" », "nearest").

14.10 ToTemporalRoundingIncrement ( options, dividend, inclusive )

  1. Set options to ? NormalizeOptionsObject(options).
  2. If dividend is undefined, then
    1. Let maximum be +∞.
  3. Else if inclusive is true, then
    1. Let maximum be dividend.
  4. Else if dividend is more than 1, then
    1. Let maximum be dividend − 1.
  5. Else,
    1. Let maximum be 1.
  6. Let increment be ? GetNumberOption(options, "roundingIncrement", 1, maximum, 1).
  7. If dividend is not undefined and dividend modulo increment is not zero, then
    1. Throw a RangeError exception.
  8. Return increment.

14.11 ToLargestTemporalUnit ( options, disallowedUnits, defaultUnit )

  1. Assert: disallowedUnits does not contain defaultUnit.
  2. Set options to ? NormalizeOptionsObject(options).
  3. Let largestUnit be ? GetOption(options, "largestUnit", "string", « "years", "months", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds" », defaultUnit).
  4. If disallowedUnits contains largestUnit, then
    1. Throw a RangeError exception.
  5. Return largestUnit.

14.12 ToSmallestTemporalUnit ( options, disallowedUnits )

  1. Set options to ? NormalizeOptionsObject(options).
  2. Let smallestUnit be ? GetOption(options, "smallestUnit", "string", « "day", "days", "hour", "hours", "minute", "minutes", "second", "seconds", "millisecond", "milliseconds", "microsecond", "microseconds", "nanosecond", "nanoseconds" », "not present").
  3. If smallestUnit is "not present", then
    1. Throw a RangeError exception.
  4. If smallestUnit is "days", then
    1. Set smallestUnit to "day".
  5. Else if smallestUnit is "hours", then
    1. Set smallestUnit to "hour".
  6. Else if smallestUnit is "minutes", then
    1. Set smallestUnit to "minute".
  7. Else if smallestUnit is "seconds", then
    1. Set smallestUnit to "second".
  8. Else if smallestUnit is "milliseconds", then
    1. Set smallestUnit to "millisecond".
  9. Else if smallestUnit is "microseconds", then
    1. Set smallestUnit to "microsecond".
  10. Else if smallestUnit is "nanoseconds", then
    1. Set smallestUnit to "nanosecond".
  11. If disallowedUnits contains smallestUnit, then
    1. Throw a RangeError exception.
  12. Return smallestUnit.

14.13 ToSmallestTemporalDurationUnit ( options, fallback, disallowedUnits )

  1. Set options to ? NormalizeOptionsObject(options).
  2. Let smallestUnit be ? GetOption(options, "smallestUnit", "string", « "year", "years", "month", "months", "week", "weeks", "day", "days", "hour", "hours", "minute", "minutes", "second", "seconds", "millisecond", "milliseconds", "microsecond", "microseconds", "nanosecond", "nanoseconds" », fallback).
  3. If smallestUnit is "year", then
    1. Set smallestUnit to "years".
  4. Else if smallestUnit is "month", then
    1. Set smallestUnit to "months".
  5. Else if smallestUnit is "week", then
    1. Set smallestUnit to "weeks".
  6. Else if smallestUnit is "day", then
    1. Set smallestUnit to "days".
  7. Else if smallestUnit is "hour", then
    1. Set smallestUnit to "hours".
  8. Else if smallestUnit is "minute", then
    1. Set smallestUnit to "minutes".
  9. Else if smallestUnit is "second", then
    1. Set smallestUnit to "seconds".
  10. Else if smallestUnit is "millisecond", then
    1. Set smallestUnit to "milliseconds".
  11. Else if smallestUnit is "microsecond", then
    1. Set smallestUnit to "microseconds".
  12. Else if smallestUnit is "nanosecond", then
    1. Set smallestUnit to "nanoseconds".
  13. If disallowedUnits contains smallestUnit, then
    1. Throw a RangeError exception.
  14. Return smallestUnit.

14.14 ValidateTemporalDifferenceUnits ( largestUnit, smallestUnit )

  1. If smallestUnit is "years" and largestUnit is not "years", then
    1. Throw a RangeError exception.
  2. If smallestUnit is "months" and largestUnit is not "years" or "months", then
    1. Throw a RangeError exception.
  3. If smallestUnit is "weeks" and largestUnit is not one of "years", "months", or "weeks"