Stage 3 Draft / November 24, 2021

Temporal proposal

Introduction

The venerable ECMAScript Date object has a number of challenges, including lack of immutability, lack of support for time zones, lack of support for use cases that require dates only or times only, a confusing and non-ergonomic API, and many other challenges.

The Temporal set of types addresses these challenges with a built-in date and time API for ECMAScript that includes:

Figure 1: Temporal Object Relationships
Figure 2: Temporal String Persistence

This specification consists of three parts:

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 Value Properties of the Temporal Object

1.1.1 Temporal [ @@toStringTag ]

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

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

1.2 Constructor Properties of the Temporal Object

1.2.1 Temporal.Instant ( . . . )

See 8.

1.2.2 Temporal.PlainDateTime ( . . . )

See 5.

1.2.3 Temporal.PlainDate ( . . . )

See 3.

1.2.4 Temporal.PlainTime ( . . . )

See 4.

1.2.5 Temporal.PlainYearMonth ( . . . )

See 9.

1.2.6 Temporal.PlainMonthDay ( . . . )

See 10.

1.2.7 Temporal.TimeZone ( . . . )

See 11.

1.2.8 Temporal.Duration ( . . . )

See 7.

1.3 Other Properties of the Temporal Object

1.3.1 Temporal.Now

See 2.

2 The Temporal.Now Object

The Temporal.Now 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.

2.1 Value Properties of the Temporal.Now Object

2.1.1 Temporal.Now [ @@toStringTag ]

The initial value of the @@toStringTag property is the String value "Temporal.Now".

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

2.2 Function Properties of the Temporal.Now Object

2.2.1 Temporal.Now.timeZone ( )

The following steps are taken:

  1. Return ! SystemTimeZone().

2.2.2 Temporal.Now.instant ( )

The following steps are taken:

  1. Return ! SystemInstant().

2.2.3 Temporal.Now.plainDateTime ( calendar [ , temporalTimeZoneLike ] )

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

  1. Return ? SystemDateTime(temporalTimeZoneLike, calendar).

2.2.4 Temporal.Now.plainDateTimeISO ( [ temporalTimeZoneLike ] )

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

  1. Let calendar be ! GetISO8601Calendar().
  2. Return ? SystemDateTime(temporalTimeZoneLike, calendar).

2.2.5 Temporal.Now.zonedDateTime ( calendar [ , temporalTimeZoneLike ] )

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

  1. Return ? SystemZonedDateTime(temporalTimeZoneLike, calendar).

2.2.6 Temporal.Now.zonedDateTimeISO ( [ temporalTimeZoneLike ] )

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

  1. Let calendar be ! GetISO8601Calendar().
  2. Return ? SystemZonedDateTime(temporalTimeZoneLike, calendar).

2.2.7 Temporal.Now.plainDate ( calendar [ , temporalTimeZoneLike ] )

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

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

2.2.8 Temporal.Now.plainDateISO ( [ temporalTimeZoneLike ] )

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

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

2.2.9 Temporal.Now.plainTimeISO ( [ temporalTimeZoneLike ] )

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

  1. Let calendar be ! GetISO8601Calendar().
  2. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
  3. Return ! CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).

2.3 Abstract operations

2.3.1 SystemTimeZone ( )

  1. Let identifier be ! DefaultTimeZone().
  2. Return ! CreateTemporalTimeZone(identifier).

2.3.2 SystemUTCEpochNanoseconds ( )

  1. Let ns be the approximate current UTC date and time, in nanoseconds since the epoch.
  2. Set ns to the result of clamping ns between −8.64 × 1021 and 8.64 × 1021.
  3. Return ℤ(ns).
Note 1

The precision of the result depends on the host. In particular, web browsers artificially limit it to prevent abuse of security flaws (e.g., Spectre) and to avoid certain methods of fingerprinting.

Note 2

Step 2 is necessary if the system clock is set to a time outside the range that Temporal.Instant can represent. This is not expected to affect implementations in practice.

2.3.3 SystemInstant ( )

  1. Let ns be ! SystemUTCEpochNanoseconds().
  2. Return ! CreateTemporalInstant(ns).

2.3.4 SystemDateTime ( temporalTimeZoneLike, calendarLike )

  1. If temporalTimeZoneLike is undefined, then
    1. Let timeZone be ! SystemTimeZone().
  2. Else,
    1. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  3. Let calendar be ? ToTemporalCalendar(calendarLike).
  4. Let instant be ! SystemInstant().
  5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).

2.3.5 SystemZonedDateTime ( temporalTimeZoneLike, calendarLike )

  1. If temporalTimeZoneLike is undefined, then
    1. Let timeZone be ! SystemTimeZone().
  2. Else,
    1. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  3. Let calendar be ? ToTemporalCalendar(calendarLike).
  4. Let ns be ! SystemUTCEpochNanoseconds().
  5. Return ! CreateTemporalZonedDateTime(ns, timeZone, calendar).

3 Temporal.PlainDate Objects

A Temporal.PlainDate object is an Object that contains integers corresponding to a particular year, month, and day in the ISO8601 calendar, as well as an Object value used to interpret those integers in a particular calendar.

3.1 The Temporal.PlainDate Constructor

The Temporal.PlainDate constructor:

  • creates and initializes a new Temporal.PlainDate object when called as a constructor.
  • is not intended to be called as a function and will throw an exception when called in that manner.
  • may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.PlainDate behaviour must include a super call to the %Temporal.PlainDate% constructor to create and initialize subclass instances with the necessary internal slots.

3.1.1 Temporal.PlainDate ( isoYear, isoMonth, isoDay [ , calendarLike ] )

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

Note
The value of ? ToIntegerThrowOnInfinity(undefined) is 0.
  1. If NewTarget is undefined, throw a TypeError exception.
  2. Let y be ? ToIntegerThrowOnInfinity(isoYear).
  3. Let m be ? ToIntegerThrowOnInfinity(isoMonth).
  4. Let d be ? ToIntegerThrowOnInfinity(isoDay).
  5. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
  6. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget).

3.2 Properties of the Temporal.PlainDate Constructor

The Temporal.PlainDate constructor:

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

3.2.1 Temporal.PlainDate.prototype

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

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

3.2.2 Temporal.PlainDate.from ( item [ , options ] )

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

  1. Set options to ? GetOptionsObject(options).
  2. If Type(item) is Object and item has an [[InitializedTemporalDate]] internal slot, then
    1. Perform ? ToTemporalOverflow(options).
    2. Return ? CreateTemporalDate(item.[[ISOYear]], item.[[ISOMonth]], item.[[ISODay]], item.[[Calendar]]).
  3. Return ? ToTemporalDate(item, options).

3.2.3 Temporal.PlainDate.compare ( one, two )

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

  1. Set one to ? ToTemporalDate(one).
  2. Set two to ? ToTemporalDate(two).
  3. Return 𝔽(! CompareISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]])).

3.3 Properties of the Temporal.PlainDate Prototype Object

The Temporal.PlainDate prototype object

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

3.3.1 Temporal.PlainDate.prototype.constructor

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

3.3.2 Temporal.PlainDate.prototype[ @@toStringTag ]

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

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

3.3.3 get Temporal.PlainDate.prototype.calendar

Temporal.PlainDate.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.PlainDate.prototype.year

Temporal.PlainDate.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. Return ? CalendarYear(calendar, temporalDate).

3.3.5 get Temporal.PlainDate.prototype.month

Temporal.PlainDate.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. Return ? CalendarMonth(calendar, temporalDate).

3.3.6 get Temporal.PlainDate.prototype.monthCode

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

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

3.3.7 get Temporal.PlainDate.prototype.day

Temporal.PlainDate.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. Return ? CalendarDay(calendar, temporalDate).

3.3.8 get Temporal.PlainDate.prototype.dayOfWeek

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

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

3.3.9 get Temporal.PlainDate.prototype.dayOfYear

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

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

3.3.10 get Temporal.PlainDate.prototype.weekOfYear

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

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

3.3.11 get Temporal.PlainDate.prototype.daysInWeek

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

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

3.3.12 get Temporal.PlainDate.prototype.daysInMonth

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

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

3.3.13 get Temporal.PlainDate.prototype.daysInYear

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

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

3.3.14 get Temporal.PlainDate.prototype.monthsInYear

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

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

3.3.15 get Temporal.PlainDate.prototype.inLeapYear

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

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

3.3.16 Temporal.PlainDate.prototype.toPlainYearMonth ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let fieldNames be ? CalendarFields(calendar, « "monthCode", "year" »).
  5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
  6. Return ? YearMonthFromFields(calendar, fields).

3.3.17 Temporal.PlainDate.prototype.toPlainMonthDay ( )

The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be temporalDate.[[Calendar]].
  4. Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »).
  5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
  6. Return ? MonthDayFromFields(calendar, fields).

3.3.18 Temporal.PlainDate.prototype.getISOFields ( )

The following steps are taken:

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

3.3.19 Temporal.PlainDate.prototype.add ( temporalDurationLike [ , options ] )

The add 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 ? ToTemporalDuration(temporalDurationLike).
  4. Set options to ? GetOptionsObject(options).
  5. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate, duration, options).

3.3.20 Temporal.PlainDate.prototype.subtract ( temporalDurationLike [ , options ] )

The subtract 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 ? ToTemporalDuration(temporalDurationLike).
  4. Set options to ? GetOptionsObject(options).
  5. Let negatedDuration be ! CreateNegatedTemporalDuration(duration).
  6. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate, negatedDuration, options).

3.3.21 Temporal.PlainDate.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. If Type(temporalDateLike) is not Object, then
    1. Throw a TypeError exception.
  4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateLike).
  5. Let calendar be temporalDate.[[Calendar]].
  6. Let fieldNames be ? CalendarFields(calendar, « "day", "month", "monthCode", "year" »).
  7. Let partialDate be ? PreparePartialTemporalFields(temporalDateLike, fieldNames).
  8. Set options to ? GetOptionsObject(options).
  9. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
  10. Set fields to ? CalendarMergeFields(calendar, fields, partialDate).
  11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
  12. Return ? DateFromFields(calendar, fields, options).

3.3.22 Temporal.PlainDate.prototype.withCalendar ( calendar )

The withCalendar method takes one argument calendar. The following steps are taken:

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Let calendar be ? ToTemporalCalendar(calendar).
  4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar).

3.3.23 Temporal.PlainDate.prototype.until ( other [ , options ] )

The until 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. Set other to ? ToTemporalDate(other).
  4. If ? CalendarEquals(temporalDate.[[Calendar]], other.[[Calendar]]) is false, throw a RangeError exception.
  5. Set options to ? GetOptionsObject(options).
  6. Let disallowedUnits be « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" ».
  7. Let smallestUnit be ? ToSmallestTemporalUnit(options, disallowedUnits, "day").
  8. Let largestUnit be ? ToLargestTemporalUnit(options, disallowedUnits, "auto", "day").
  9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  10. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  11. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, undefined, false).
  12. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
  13. Let result be ? CalendarDateUntil(temporalDate.[[Calendar]], temporalDate, other, untilOptions).
  14. If smallestUnit is not "day" or roundingIncrement ≠ 1, then
    1. Set result to ? RoundDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0, roundingIncrement, smallestUnit, roundingMode, temporalDate).
  15. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0).

3.3.24 Temporal.PlainDate.prototype.since ( other [ , options ] )

The since 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. Set other to ? ToTemporalDate(other).
  4. If ? CalendarEquals(temporalDate.[[Calendar]], other.[[Calendar]]) is false, throw a RangeError exception.
  5. Set options to ? GetOptionsObject(options).
  6. Let disallowedUnits be « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" ».
  7. Let smallestUnit be ? ToSmallestTemporalUnit(options, disallowedUnits, "day").
  8. Let largestUnit be ? ToLargestTemporalUnit(options, disallowedUnits, "auto", "day").
  9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  10. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  11. Set roundingMode to ! NegateTemporalRoundingMode(roundingMode).
  12. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, undefined, false).
  13. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
  14. Let result be ? CalendarDateUntil(temporalDate.[[Calendar]], temporalDate, other, untilOptions).
  15. If smallestUnit is "day" and roundingIncrement = 1, then
    1. Return ? CreateTemporalDuration(−result.[[Years]], −result.[[Months]], −result.[[Weeks]], −result.[[Days]], 0, 0, 0, 0, 0, 0).
  16. Set result to ? RoundDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0, roundingIncrement, smallestUnit, roundingMode, temporalDate).
  17. Return ? CreateTemporalDuration(−result.[[Years]], −result.[[Months]], −result.[[Weeks]], −result.[[Days]], 0, 0, 0, 0, 0, 0).

3.3.25 Temporal.PlainDate.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. Set other to ? ToTemporalDate(other).
  4. If temporalDate.[[ISOYear]] ≠ other.[[ISOYear]], return false.
  5. If temporalDate.[[ISOMonth]] ≠ other.[[ISOMonth]], return false.
  6. If temporalDate.[[ISODay]] ≠ other.[[ISODay]], return false.
  7. Return ? CalendarEquals(temporalDate.[[Calendar]], other.[[Calendar]]).

3.3.26 Temporal.PlainDate.prototype.toPlainDateTime ( [ temporalTime ] )

The toPlainDateTime method takes one 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, temporalDate.[[Calendar]]).
  4. Set temporalTime to ? ToTemporalTime(temporalTime).
  5. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).

3.3.27 Temporal.PlainDate.prototype.toZonedDateTime ( item )

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

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. If Type(item) is Object, then
    1. Let timeZoneLike be ? Get(item, "timeZone").
    2. If timeZoneLike is undefined, then
      1. Let timeZone be ? ToTemporalTimeZone(item).
      2. Let temporalTime be undefined.
    3. Else,
      1. Let timeZone be ? ToTemporalTimeZone(timeZoneLike).
      2. Let temporalTime be ? Get(item, "plainTime").
  4. Else,
    1. Let timeZone be ? ToTemporalTimeZone(item).
    2. Let temporalTime be undefined.
  5. If temporalTime is undefined, then
    1. Let temporalDateTime be ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], 0, 0, 0, 0, 0, 0, temporalDate.[[Calendar]]).
  6. Else,
    1. Set temporalTime to ? ToTemporalTime(temporalTime).
    2. Let temporalDateTime be ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
  7. Let instant be ? BuiltinTimeZoneGetInstantFor(timeZone, temporalDateTime, "compatible").
  8. Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, temporalDate.[[Calendar]]).

3.3.28 Temporal.PlainDate.prototype.toString ( [ options ] )

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

  1. Let temporalDate be the this value.
  2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
  3. Set options to ? GetOptionsObject(options).
  4. Let showCalendar be ? ToShowCalendarOption(options).
  5. Return ? TemporalDateToString(temporalDate, showCalendar).

3.3.29 Temporal.PlainDate.prototype.toLocaleString ( [ locales [ , options ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Temporal.PlainDate.prototype.toLocaleString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString method is used.

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. Return ? TemporalDateToString(temporalDate, "auto").

3.3.30 Temporal.PlainDate.prototype.toJSON ( )

The following steps are taken:

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

3.3.31 Temporal.PlainDate.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

3.4 Properties of Temporal.PlainDate Instances

Temporal.PlainDate instances are ordinary objects that inherit properties from the %Temporal.PlainDate.prototype% intrinsic object. Temporal.PlainDate instances are initially created with the internal slots described in Table 1.

Table 1: Internal Slots of Temporal.PlainDate Instances
Internal Slot Description
[[InitializedTemporalDate]] The only specified use of this slot is for distinguishing Temporal.PlainDate instances from other objects.
[[ISOYear]] An integer representing the year in the ISO 8601 calendar.
[[ISOMonth]] An integer between 1 and 12, inclusive, representing the month of the year in the ISO 8601 calendar.
[[ISODay]] An integer between 1 and ISODaysInMonth([[ISOYear]], [[ISOMonth]]), inclusive, representing the day of the month in the ISO 8601 calendar.
[[Calendar]] An Object representing the calendar.

3.5 Abstract Operations for Temporal.PlainDate Objects

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

  1. Assert: isoYear is an integer.
  2. Assert: isoMonth is an integer.
  3. Assert: isoDay is an integer.
  4. Assert: Type(calendar) is Object.
  5. If ! IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception.
  6. If ! ISODateTimeWithinLimits(isoYear, isoMonth, isoDay, 12, 0, 0, 0, 0, 0) is false, throw a RangeError exception.
  7. If newTarget is not present, set it to %Temporal.PlainDate%.
  8. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainDate.prototype%", « [[InitializedTemporalDate]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[Calendar]] »).
  9. Set object.[[ISOYear]] to isoYear.
  10. Set object.[[ISOMonth]] to isoMonth.
  11. Set object.[[ISODay]] to isoDay.
  12. Set object.[[Calendar]] to calendar.
  13. Return object.
Note

Deferring to ISODateTimeWithinLimits 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 ToTemporalDate ( item [ , options ] )

The abstract operation ToTemporalDate returns its argument item if it is already a Temporal.PlainDate instance, converts item to a new Temporal.PlainDate instance if possible, and throws otherwise.

  1. If options is not present, set options to ! OrdinaryObjectCreate(null).
  2. Assert: Type(options) is Object.
  3. If Type(item) is Object, then
    1. If item has an [[InitializedTemporalDate]] internal slot, then
      1. Return item.
    2. If item has an [[InitializedTemporalZonedDateTime]] internal slot, then
      1. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
      2. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
      3. Return ! CreateTemporalDate(plainDateTime.[[ISOYear]], plainDateTime.[[ISOMonth]], plainDateTime.[[ISODay]], plainDateTime.[[Calendar]]).
    3. If item has an [[InitializedTemporalDateTime]] internal slot, then
      1. Return ! CreateTemporalDate(item.[[ISOYear]], item.[[ISOMonth]], item.[[ISODay]], item.[[Calendar]]).
    4. Let calendar be ? GetTemporalCalendarWithISODefault(item).
    5. Let fieldNames be ? CalendarFields(calendar, « "day", "month", "monthCode", "year" »).
    6. Let fields be ? PrepareTemporalFields(item, fieldNames, «»).
    7. Return ? DateFromFields(calendar, fields, options).
  4. Perform ? ToTemporalOverflow(options).
  5. Let string be ? ToString(item).
  6. Let result be ? ParseTemporalDateString(string).
  7. Assert: ! IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
  9. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).

3.5.3 DifferenceISODate ( y1, m1, d1, y2, m2, d2, largestUnit )

  1. Assert: largestUnit is one of "year", "month", "week", or "day".
  2. If largestUnit is "year" or "month", then
    1. Let sign be -(! CompareISODate(y1, m1, d1, y2, m2, d2)).
    2. If sign is 0, return the Record { [[Years]]: 0, [[Months]]: 0, [[Weeks]]: 0, [[Days]]: 0 }.
    3. Let start be the Record { [[Year]]: y1, [[Month]]: m1, [[Day]]: d1 }.
    4. Let end be the Record { [[Year]]: y2, [[Month]]: m2, [[Day]]: d2 }.
    5. Let years be end.[[Year]] − start.[[Year]].
    6. Let mid be ! AddISODate(y1, m1, d1, years, 0, 0, 0, "constrain").
    7. Let midSign be -(! CompareISODate(mid.[[Year]], mid.[[Month]], mid.[[Day]], y2, m2, d2)).
    8. If midSign is 0, then
      1. If largestUnit is "year", return the Record { [[Years]]: years, [[Months]]: 0, [[Weeks]]: 0, [[Days]]: 0 }.
      2. Return the Record { [[Years]]: 0, [[Months]]: years × 12, [[Weeks]]: 0, [[Days]]: 0 }.
    9. Let months be end.[[Month]] − start.[[Month]].
    10. If midSign is not equal to sign, then
      1. Set years to years - sign.
      2. Set months to months + sign × 12.
    11. Set mid to ! AddISODate(y1, m1, d1, years, months, 0, 0, "constrain").
    12. Set midSign to -(! CompareISODate(mid.[[Year]], mid.[[Month]], mid.[[Day]], y2, m2, d2)).
    13. If midSign is 0, then
      1. If largestUnit is "year", return the Record { [[Years]]: years, [[Months]]: months, [[Weeks]]: 0, [[Days]]: 0 }.
      2. Return the Record { [[Years]]: 0, [[Months]]: months + years × 12, [[Weeks]]: 0, [[Days]]: 0 }.
    14. If midSign is not equal to sign, then
      1. Set months to months - sign.
      2. If months is equal to -sign, then
        1. Set years to years - sign.
        2. Set months to 11 × sign.
      3. Set mid to ! AddISODate(y1, m1, d1, years, months, 0, 0, "constrain").
      4. Set midSign to -(! CompareISODate(mid.[[Year]], mid.[[Month]], mid.[[Day]], y2, m2, d2)).
    15. Let days be 0.
    16. If mid.[[Month]] = end.[[Month]], then
      1. Assert: mid.[[Year]] = end.[[Year]].
      2. Set days to end.[[Day]] - mid.[[Day]].
    17. Else if sign < 0, set days to -mid.[[Day]] - (! ISODaysInMonth(end.[[Year]], end.[[Month]]) - end.[[Day]]).
    18. Else, set days to end.[[Day]] + (! ISODaysInMonth(mid.[[Year]], mid.[[Month]]) - mid.[[Day]]).
    19. If largestUnit is "month", then
      1. Set months to months + years × 12.
      2. Set years to 0.
    20. Return the Record { [[Years]]: years, [[Months]]: months, [[Weeks]]: 0, [[Days]]: days }.
  3. If largestUnit is "day" or "week", then
    1. If ! CompareISODate(y1, m1, d1, y2, m2, d2) < 0, then
      1. Let smaller be the Record { [[Year]]: y1, [[Month]]: m1, [[Day]]: d1 }.
      2. Let greater be the Record { [[Year]]: y2, [[Month]]: m2, [[Day]]: d2 }.
      3. Let sign be 1.
    2. Else,
      1. Let smaller be the Record { [[Year]]: y2, [[Month]]: m2, [[Day]]: d2 }.
      2. Let greater be the Record { [[Year]]: y1, [[Month]]: m1, [[Day]]: d1 }.
      3. Let sign be −1.
    3. Let days be ! ToISODayOfYear(greater.[[Year]], greater.[[Month]], greater.[[Day]]) − ! ToISODayOfYear(smaller.[[Year]], smaller.[[Month]], smaller.[[Day]]).
    4. Let year be smaller.[[Year]].
    5. Repeat, while year < greater.[[Year]],
      1. Set days to days + ! ISODaysInYear(year).
      2. Set year to year + 1.
    6. Let weeks be 0.
    7. If largestUnit is "week", then
      1. Set weeks to floor(days / 7).
      2. Set days to days modulo 7.
    8. Return the Record { [[Years]]: 0, [[Months]]: 0, [[Weeks]]: weeks × sign, [[Days]]: days × sign }.

3.5.4 RegulateISODate ( year, month, day, overflow )

  1. Assert: year, month, and day are integers.
  2. Assert: overflow is either "constrain" or "reject".
  3. If overflow is "reject", then
    1. If ! IsValidISODate(year, month, day) is false, throw a RangeError exception.
    2. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
  4. If overflow is "constrain", then
    1. Set month to ! ConstrainToRange(month, 1, 12).
    2. Set day to ! ConstrainToRange(day, 1, ! ISODaysInMonth(year, month)).
    3. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.

3.5.5 IsValidISODate ( year, month, day )

The abstract operation IsValidISODate returns true if its arguments form a valid date in the ISO 8601 calendar, and false otherwise. This includes dates that may fall outside of the allowed range for Temporal.

  1. Assert: year, month, and day are integers.
  2. If month < 1 or month > 12, then
    1. Return false.
  3. Let daysInMonth be ! ISODaysInMonth(year, month).
  4. If day < 1 or day > daysInMonth, then
    1. Return false.
  5. Return true.

3.5.6 BalanceISODate ( year, month, day )

  1. Assert: year, month, and day are integers.
  2. Let balancedYearMonth be ! BalanceISOYearMonth(year, month).
  3. Set month to balancedYearMonth.[[Month]].
  4. Set year to 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. If month > 2, then
    1. Let testYear be year.
  7. Else,
    1. Let testYear be year − 1.
  8. Repeat, while day < −1 × ! ISODaysInYear(testYear),
    1. Set day to day + ! ISODaysInYear(testYear).
    2. Set year to year − 1.
    3. Set testYear to testYear − 1.
  9. 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.
  10. Let testYear be year + 1.
  11. Repeat, while day > ! ISODaysInYear(testYear),
    1. Set day to day − ! ISODaysInYear(testYear).
    2. Set year to year + 1.
    3. Set testYear to testYear + 1.
  12. NOTE: To deal with negative numbers of days whose absolute value is 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.
  13. Repeat, while day < 1,
    1. Set balancedYearMonth to ! BalanceISOYearMonth(year, month − 1).
    2. Set year to balancedYearMonth.[[Year]].
    3. Set month to balancedYearMonth.[[Month]].
    4. Set day to day + ! ISODaysInMonth(year, month).
  14. 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.
  15. Repeat, while day > ! ISODaysInMonth(year, month),
    1. Set day to day − ! ISODaysInMonth(year, month).
    2. Set balancedYearMonth to ! BalanceISOYearMonth(year, month + 1).
    3. Set year to balancedYearMonth.[[Year]].
    4. Set month to balancedYearMonth.[[Month]].
  16. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.

3.5.7 PadISOYear ( y )

  1. Assert: y is an integer.
  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.8 TemporalDateToString ( temporalDate, showCalendar )

  1. Assert: Type(temporalDate) is Object.
  2. Assert: temporalDate has an [[InitializedTemporalDate]] internal slot.
  3. Let year be ! PadISOYear(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. Let calendarID be ? ToString(temporalDate.[[Calendar]]).
  7. Let calendar be ! FormatCalendarAnnotation(calendarID, showCalendar).
  8. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, and calendar.

3.5.9 AddISODate ( year, month, day, years, months, weeks, days, overflow )

  1. Assert: year, month, day, years, months, weeks, and days are integers.
  2. Assert: overflow is either "constrain" or "reject".
  3. Let intermediate be ! BalanceISOYearMonth(year + years, month + months).
  4. Let intermediate be ? RegulateISODate(intermediate.[[Year]], intermediate.[[Month]], day, overflow).
  5. Set days to days + 7 × weeks.
  6. Let d be intermediate.[[Day]] + days.
  7. Let intermediate be ! BalanceISODate(intermediate.[[Year]], intermediate.[[Month]], d).
  8. Return ? RegulateISODate(intermediate.[[Year]], intermediate.[[Month]], intermediate.[[Day]], overflow).

3.5.10 CompareISODate ( y1, m1, d1, y2, m2, d2 )

  1. Assert: y1, m1, d1, y2, m2, and d2 are integers.
  2. If y1 > y2, return 1.
  3. If y1 < y2, return -1.
  4. If m1 > m2, return 1.
  5. If m1 < m2, return -1.
  6. If d1 > d2, return 1.
  7. If d1 < d2, return -1.
  8. Return 0.

4 Temporal.PlainTime Objects

A Temporal.PlainTime object is an Object that contains integers corresponding to a particular hour, minute, second, millisecond, microsecond, and nanosecond.

4.1 The Temporal.PlainTime Constructor

The Temporal.PlainTime constructor:

  • creates and initializes a new Temporal.PlainTime object when called as a constructor.
  • is not intended to be called as a function and will throw an exception when called in that manner.
  • may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.PlainTime behaviour must include a super call to the %Temporal.PlainTime% constructor to create and initialize subclass instances with the necessary internal slots.

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

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

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

4.2 Properties of the Temporal.PlainTime Constructor

The value of the [[Prototype]] internal slot of the Temporal.PlainTime constructor is the intrinsic object %Function.prototype%.

The Temporal.PlainTime constructor has the following properties:

4.2.1 Temporal.PlainTime.prototype

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

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

4.2.2 Temporal.PlainTime.from ( item [ , options ] )

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

  1. Set options to ? GetOptionsObject(options).
  2. Let overflow be ? ToTemporalOverflow(options).
  3. If Type(item) is Object and item has an [[InitializedTemporalTime]] internal slot, then
    1. Return ? CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]).
  4. Return ? ToTemporalTime(item, overflow).

4.2.3 Temporal.PlainTime.compare ( one, two )

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

  1. Set one to ? ToTemporalTime(one).
  2. Set two to ? ToTemporalTime(two).
  3. Return 𝔽(! CompareTemporalTime(one.[[ISOHour]], one.[[ISOMinute]], one.[[ISOSecond]], one.[[ISOMillisecond]], one.[[ISOMicrosecond]], one.[[ISONanosecond]], two.[[ISOHour]], two.[[ISOMinute]], two.[[ISOSecond]], two.[[ISOMillisecond]], two.[[ISOMicrosecond]], two.[[ISONanosecond]])).

4.3 Properties of the Temporal.PlainTime Prototype Object

The Temporal.PlainTime prototype object

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

4.3.1 Temporal.PlainTime.prototype.constructor

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

4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ]

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

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

4.3.3 get Temporal.PlainTime.prototype.calendar

Temporal.PlainTime.prototype.calendar 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.[[Calendar]].

4.3.4 get Temporal.PlainTime.prototype.hour

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

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

4.3.5 get Temporal.PlainTime.prototype.minute

Temporal.PlainTime.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.[[ISOMinute]]).

4.3.6 get Temporal.PlainTime.prototype.second

Temporal.PlainTime.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.[[ISOSecond]]).

4.3.7 get Temporal.PlainTime.prototype.millisecond

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

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

4.3.8 get Temporal.PlainTime.prototype.microsecond

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

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

4.3.9 get Temporal.PlainTime.prototype.nanosecond

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

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

4.3.10 Temporal.PlainTime.prototype.add ( temporalDurationLike )

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

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Let result be ! AddTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  5. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  6. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.11 Temporal.PlainTime.prototype.subtract ( temporalDurationLike )

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

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Let result be ! AddTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]]).
  5. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  6. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.12 Temporal.PlainTime.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. If Type(temporalTimeLike) is not Object, then
    1. Throw a TypeError exception.
  4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalTimeLike).
  5. Let partialTime be ? ToPartialTime(temporalTimeLike).
  6. Set options to ? GetOptionsObject(options).
  7. Let overflow be ? ToTemporalOverflow(options).
  8. If partialTime.[[Hour]] is not undefined, then
    1. Let hour be partialTime.[[Hour]].
  9. Else,
    1. Let hour be temporalTime.[[ISOHour]].
  10. If partialTime.[[Minute]] is not undefined, then
    1. Let minute be partialTime.[[Minute]].
  11. Else,
    1. Let minute be temporalTime.[[ISOMinute]].
  12. If partialTime.[[Second]] is not undefined, then
    1. Let second be partialTime.[[Second]].
  13. Else,
    1. Let second be temporalTime.[[ISOSecond]].
  14. If partialTime.[[Millisecond]] is not undefined, then
    1. Let millisecond be partialTime.[[Millisecond]].
  15. Else,
    1. Let millisecond be temporalTime.[[ISOMillisecond]].
  16. If partialTime.[[Microsecond]] is not undefined, then
    1. Let microsecond be partialTime.[[Microsecond]].
  17. Else,
    1. Let microsecond be temporalTime.[[ISOMicrosecond]].
  18. If partialTime.[[Nanosecond]] is not undefined, then
    1. Let nanosecond be partialTime.[[Nanosecond]].
  19. Else,
    1. Let nanosecond be temporalTime.[[ISONanosecond]].
  20. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow).
  21. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.13 Temporal.PlainTime.prototype.until ( other [ , options ] )

The until 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. Set other to ? ToTemporalTime(other).
  4. Set options to ? GetOptionsObject(options).
  5. Let smallestUnit be ? ToSmallestTemporalUnit(options, « "year", "month", "week", "day" », "nanosecond").
  6. Let largestUnit be ? ToLargestTemporalUnit(options, « "year", "month", "week", "day" », "auto", "hour").
  7. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  8. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  9. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  10. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  11. Let result be ! DifferenceTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], other.[[ISOHour]], other.[[ISOMinute]], other.[[ISOSecond]], other.[[ISOMillisecond]], other.[[ISOMicrosecond]], other.[[ISONanosecond]]).
  12. Set result to ? RoundDuration(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode).
  13. Set result to ! BalanceDuration(0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], largestUnit).
  14. Return ? CreateTemporalDuration(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

4.3.14 Temporal.PlainTime.prototype.since ( other [ , options ] )

The since 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. Set other to ? ToTemporalTime(other).
  4. Set options to ? GetOptionsObject(options).
  5. Let smallestUnit be ? ToSmallestTemporalUnit(options, « "year", "month", "week", "day" », "nanosecond").
  6. Let largestUnit be ? ToLargestTemporalUnit(options, « "year", "month", "week", "day" », "auto", "hour").
  7. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  8. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  9. Set roundingMode to ! NegateTemporalRoundingMode(roundingMode).
  10. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  11. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  12. Let result be ! DifferenceTime(other.[[ISOHour]], other.[[ISOMinute]], other.[[ISOSecond]], other.[[ISOMillisecond]], other.[[ISOMicrosecond]], other.[[ISONanosecond]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]]).
  13. Set result to ? RoundDuration(0, 0, 0, 0, −result.[[Hours]], −result.[[Minutes]], −result.[[Seconds]], −result.[[Milliseconds]], −result.[[Microseconds]], −result.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode).
  14. Set result to ! BalanceDuration(0, −result.[[Hours]], −result.[[Minutes]], −result.[[Seconds]], −result.[[Milliseconds]], −result.[[Microseconds]], −result.[[Nanoseconds]], largestUnit).
  15. Return ? CreateTemporalDuration(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

4.3.15 Temporal.PlainTime.prototype.round ( roundTo )

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

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. If roundTo is undefined, then
    1. Throw a TypeError exception.
  4. If Type(roundTo) is String, then
    1. Let paramString be roundTo.
    2. Set roundTo to ! OrdinaryObjectCreate(null).
    3. Perform ! CreateDataPropertyOrThrow(roundTo, "_smallestUnit_", paramString).
  5. Else,
    1. Set roundTo to ? GetOptionsObject(roundTo).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(roundTo, « "year", "month", "week", "day" », undefined).
  7. If smallestUnit is undefined, throw a RangeError exception.
  8. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand").
  9. If smallestUnit is "hour", then
    1. Let maximum be 24.
  10. Else if smallestUnit is "minute" or "second", then
    1. Let maximum be 60.
  11. Else,
    1. Let maximum be 1000.
  12. Let roundingIncrement be ? ToTemporalRoundingIncrement(roundTo, maximum, false).
  13. Let result be ! RoundTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode).
  14. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.3.16 Temporal.PlainTime.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. Set other to ? ToTemporalTime(other).
  4. If temporalTime.[[ISOHour]] ≠ other.[[ISOHour]], return false.
  5. If temporalTime.[[ISOMinute]] ≠ other.[[ISOMinute]], return false.
  6. If temporalTime.[[ISOSecond]] ≠ other.[[ISOSecond]], return false.
  7. If temporalTime.[[ISOMillisecond]] ≠ other.[[ISOMillisecond]], return false.
  8. If temporalTime.[[ISOMicrosecond]] ≠ other.[[ISOMicrosecond]], return false.
  9. If temporalTime.[[ISONanosecond]] ≠ other.[[ISONanosecond]], return false.
  10. Return true.

4.3.17 Temporal.PlainTime.prototype.toPlainDateTime ( temporalDate )

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

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Set temporalDate to ? ToTemporalDate(temporalDate).
  4. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).

4.3.18 Temporal.PlainTime.prototype.toZonedDateTime ( item )

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

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. If Type(item) is not Object, then
    1. Throw a TypeError exception.
  4. Let temporalDateLike be ? Get(item, "plainDate").
  5. If temporalDateLike is undefined, then
    1. Throw a TypeError exception.
  6. Let temporalDate be ? ToTemporalDate(temporalDateLike).
  7. Let temporalTimeZoneLike be ? Get(item, "timeZone").
  8. If temporalTimeZoneLike is undefined, then
    1. Throw a TypeError exception.
  9. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
  10. Let temporalDateTime be ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
  11. Let instant be ? BuiltinTimeZoneGetInstantFor(timeZone, temporalDateTime, "compatible").
  12. Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, temporalDate.[[Calendar]]).

4.3.19 Temporal.PlainTime.prototype.getISOFields ( )

The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%).
  4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalTime.[[Calendar]]).
  5. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(temporalTime.[[ISOHour]])).
  6. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(temporalTime.[[ISOMicrosecond]])).
  7. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(temporalTime.[[ISOMillisecond]])).
  8. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(temporalTime.[[ISOMinute]])).
  9. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(temporalTime.[[ISONanosecond]])).
  10. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(temporalTime.[[ISOSecond]])).
  11. Return fields.

4.3.20 Temporal.PlainTime.prototype.toString ( [ options ] )

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

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Set options to ? GetOptionsObject(options).
  4. Let precision be ? ToSecondsStringPrecision(options).
  5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  6. Let roundResult be ! RoundTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], precision.[[Increment]], precision.[[Unit]], roundingMode).
  7. Return ! TemporalTimeToString(roundResult.[[Hour]], roundResult.[[Minute]], roundResult.[[Second]], roundResult.[[Millisecond]], roundResult.[[Microsecond]], roundResult.[[Nanosecond]], precision.[[Precision]]).

4.3.21 Temporal.PlainTime.prototype.toLocaleString ( [ locales [ , options ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Temporal.PlainTime.prototype.toLocaleString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString method is used.

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. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").

4.3.22 Temporal.PlainTime.prototype.toJSON ( )

The following steps are taken:

  1. Let temporalTime be the this value.
  2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
  3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").

4.3.23 Temporal.PlainTime.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

4.4 Properties of Temporal.PlainTime Instances

Temporal.PlainTime instances are ordinary objects that inherit properties from the %Temporal.PlainTime.prototype% intrinsic object. Temporal.PlainTime instances are initially created with the internal slots described in Table 2.

Table 2: Internal Slots of Temporal.PlainTime Instances
Internal Slot Description
[[InitializedTemporalTime]] The only specified use of this slot is for distinguishing Temporal.PlainTime instances from other objects.
[[ISOHour]] An integer between 0 and 23, inclusive, representing the hour of the day.
[[ISOMinute]] An integer between 0 and 59, inclusive, representing the minute of the hour.
[[ISOSecond]] An integer between 0 and 59, inclusive, representing the second within the minute.
[[ISOMillisecond]] An integer between 0 and 999, inclusive, representing the millisecond within the second.
[[ISOMicrosecond]] An integer between 0 and 999, inclusive, representing the microsecond within the millisecond.
[[ISONanosecond]] An integer between 0 and 999, inclusive, representing the nanosecond within the microsecond.
[[Calendar]] An instance of the built-in ISO 8601 calendar.

4.5 Abstract operations

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

  1. Assert: h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, and ns2 are integers.
  2. Let hours be h2h1.
  3. Let minutes be min2min1.
  4. Let seconds be s2s1.
  5. Let milliseconds be ms2ms1.
  6. Let microseconds be mus2mus1.
  7. Let nanoseconds be ns2ns1.
  8. Let sign be ! DurationSign(0, 0, 0, 0, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  9. Let bt be ! BalanceTime(hours × sign, minutes × sign, seconds × sign, milliseconds × sign, microseconds × sign, nanoseconds × sign).
  10. Return the 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.5.2 ToTemporalTime ( item [ , overflow ] )

The abstract operation ToTemporalTime returns its argument item if it is already a Temporal.PlainTime instance, converts item to a new Temporal.PlainTime instance if possible, and throws otherwise.

  1. If overflow is not present, set it to "constrain".
  2. Assert: overflow is either "constrain" or "reject".
  3. If Type(item) is Object, then
    1. If item has an [[InitializedTemporalTime]] internal slot, then
      1. Return item.
    2. If item has an [[InitializedTemporalZonedDateTime]] internal slot, then
      1. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
      2. Set plainDateTime to ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
      3. Return ! CreateTemporalTime(plainDateTime.[[ISOHour]], plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]], plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]], plainDateTime.[[ISONanosecond]]).
    3. If item has an [[InitializedTemporalDateTime]] internal slot, then
      1. Return ! CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]).
    4. Let calendar be ? GetTemporalCalendarWithISODefault(item).
    5. If ? ToString(calendar) is not "iso8601", then
      1. Throw a RangeError exception.
    6. Let result be ? ToTemporalTimeRecord(item).
    7. Set result to ? RegulateTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], overflow).
  4. Else,
    1. Let string be ? ToString(item).
    2. Let result be ? ParseTemporalTimeString(string).
    3. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
    4. If result.[[Calendar]] is not one of undefined or "iso8601", then
      1. Throw a RangeError exception.
  5. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).

4.5.3 ToPartialTime ( temporalTimeLike )

  1. Assert: Type(temporalTimeLike) is Object.
  2. Let result be the Record { [[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(temporalTimeLike, property).
    3. If value is not undefined, then
      1. Set any to true.
      2. Set value to ? ToIntegerThrowOnInfinity(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: Properties of a TemporalTimeLike
Internal Slot Property
[[Hour]] "hour"
[[Microsecond]] "microsecond"
[[Millisecond]] "millisecond"
[[Minute]] "minute"
[[Nanosecond]] "nanosecond"
[[Second]] "second"

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

  1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers.
  2. Assert: overflow is either "constrain" or "reject".
  3. If overflow is "constrain", then
    1. Return ! ConstrainTime(hour, minute, second, millisecond, microsecond, nanosecond).
  4. If overflow is "reject", then
    1. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
    2. Return the Record { [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.

4.5.5 IsValidTime ( hour, minute, second, millisecond, microsecond, nanosecond )

The abstract operation IsValidTime returns true if its arguments form a valid time of day, and false otherwise. Leap seconds are not taken into account.

  1. Assert: hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  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.5.6 BalanceTime ( hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Set microsecond to microsecond + floor(nanosecond / 1000).
  3. Set nanosecond to nanosecond modulo 1000.
  4. Set millisecond to millisecond + floor(microsecond / 1000).
  5. Set microsecond to microsecond modulo 1000.
  6. Set second to second + floor(millisecond / 1000).
  7. Set millisecond to millisecond modulo 1000.
  8. Set minute to minute + floor(second / 60).
  9. Set second to second modulo 60.
  10. Set hour to hour + floor(minute / 60).
  11. Set minute to minute modulo 60.
  12. Let days be floor(hour / 24).
  13. Set hour to hour modulo 24.
  14. Return the Record { [[Days]]: days, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.

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

  1. Assert: hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  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.5.8 CreateTemporalTime ( hour, minute, second, millisecond, microsecond, nanosecond [ , newTarget ] )

  1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers.
  2. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
  3. If newTarget is not present, set it to %Temporal.PlainTime%.
  4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainTime.prototype%", « [[InitializedTemporalTime]], [[ISOHour]], [[ISOMinute]], [[ISOSecond]], [[ISOMillisecond]], [[ISOMicrosecond]], [[ISONanosecond]], [[Calendar]] »).
  5. Set object.[[ISOHour]] to hour.
  6. Set object.[[ISOMinute]] to minute.
  7. Set object.[[ISOSecond]] to second.
  8. Set object.[[ISOMillisecond]] to millisecond.
  9. Set object.[[ISOMicrosecond]] to microsecond.
  10. Set object.[[ISONanosecond]] to nanosecond.
  11. Set object.[[Calendar]] to ! GetISO8601Calendar().
  12. Return object.

4.5.9 ToTemporalTimeRecord ( temporalTimeLike )

Note
The value of ? ToIntegerThrowOnInfinity(undefined) is 0.
  1. Assert: Type(temporalTimeLike) is Object.
  2. Let result be the Record { [[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(temporalTimeLike, property).
    3. If value is not undefined, then
      1. Set any to true.
    4. Set value to ? ToIntegerThrowOnInfinity(value).
    5. 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.

4.5.10 TemporalTimeToString ( hour, minute, second, millisecond, microsecond, nanosecond, precision )

  1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers.
  2. Let hour be hour formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  3. Let minute be minute formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  4. Let seconds be ! FormatSecondsStringPart(second, millisecond, microsecond, nanosecond, precision).
  5. Return the string-concatenation of hour, the code unit 0x003A (COLON), minute, and seconds.

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

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

4.5.12 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 integers.
  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.5.13 RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, roundingMode [ , dayLengthNs ] )

The abstract operation RoundTime rounds a time to the given increment, optionally adjusting for a non-24-hour day.

  1. Assert: hour, minute, second, millisecond, microsecond, nanosecond, and increment are integers.
  2. Let fractionalSecond be nanosecond × 10−9 + microsecond × 10−6 + millisecond × 10−3 + second.
  3. If unit is "day", then
    1. If dayLengthNs is not present, set it to 8.64 × 1013.
    2. Let quantity be (((((hour × 60 + minute) × 60 + second) × 1000 + millisecond) × 1000 + microsecond) × 1000 + nanosecond) / dayLengthNs.
  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 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.PlainDateTime Objects

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

5.1 The Temporal.PlainDateTime Constructor

The Temporal.PlainDateTime constructor:

  • creates and initializes a new Temporal.PlainDateTime object when called as a constructor.
  • is not intended to be called as a function and will throw an exception when called in that manner.
  • may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.PlainDateTime behaviour must include a super call to the %Temporal.PlainDateTime% constructor to create and initialize subclass instances with the necessary internal slots.

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

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

Note
The value of ? ToIntegerThrowOnInfinity(undefined) is 0.
  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let isoYear be ? ToIntegerThrowOnInfinity(isoYear).
  3. Let isoMonth be ? ToIntegerThrowOnInfinity(isoMonth).
  4. Let isoDay be ? ToIntegerThrowOnInfinity(isoDay).
  5. Let hour be ? ToIntegerThrowOnInfinity(hour).
  6. Let minute be ? ToIntegerThrowOnInfinity(minute).
  7. Let second be ? ToIntegerThrowOnInfinity(second).
  8. Let millisecond be ? ToIntegerThrowOnInfinity(millisecond).
  9. Let microsecond be ? ToIntegerThrowOnInfinity(microsecond).
  10. Let nanosecond be ? ToIntegerThrowOnInfinity(nanosecond).
  11. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
  12. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, NewTarget).

5.2 Properties of the Temporal.PlainDateTime Constructor

The value of the [[Prototype]] internal slot of the Temporal.PlainDateTime constructor is the intrinsic object %Function.prototype%.

The Temporal.PlainDateTime constructor has the following properties:

5.2.1 Temporal.PlainDateTime.prototype

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

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

5.2.2 Temporal.PlainDateTime.from ( item [ , options ] )

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

  1. Set options to ? GetOptionsObject(options).
  2. If Type(item) is Object and item has an [[InitializedTemporalDateTime]] internal slot, then
    1. Perform ? ToTemporalOverflow(options).
    2. Return ? CreateTemporalDateTime(item.[[ISOYear]], item.[[ISOMonth]], item.[[ISODay]], item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]], item.[[Calendar]]).
  3. Return ? ToTemporalDateTime(item, options).

5.2.3 Temporal.PlainDateTime.compare ( one, two )

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

  1. Set one to ? ToTemporalDateTime(one).
  2. Set two to ? ToTemporalDateTime(two).
  3. Return 𝔽(! CompareISODateTime(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], one.[[ISOHour]], one.[[ISOMinute]], one.[[ISOSecond]], one.[[ISOMillisecond]], one.[[ISOMicrosecond]], one.[[ISONanosecond]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], two.[[ISOHour]], two.[[ISOMinute]], two.[[ISOSecond]], two.[[ISOMillisecond]], two.[[ISOMicrosecond]], two.[[ISONanosecond]])).

5.3 Properties of the Temporal.PlainDateTime Prototype Object

The Temporal.PlainDateTime prototype object

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

5.3.1 Temporal.PlainDateTime.prototype.constructor

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

5.3.2 Temporal.PlainDateTime.prototype[ @@toStringTag ]

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

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

5.3.3 get Temporal.PlainDateTime.prototype.calendar

Temporal.PlainDateTime.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.PlainDateTime.prototype.year

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

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

5.3.5 get Temporal.PlainDateTime.prototype.month

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

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

5.3.6 get Temporal.PlainDateTime.prototype.monthCode

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

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

5.3.7 get Temporal.PlainDateTime.prototype.day

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

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

5.3.8 get Temporal.PlainDateTime.prototype.hour

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

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

5.3.9 get Temporal.PlainDateTime.prototype.minute

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

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

5.3.10 get Temporal.PlainDateTime.prototype.second

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

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

5.3.11 get Temporal.PlainDateTime.prototype.millisecond

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

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

5.3.12 get Temporal.PlainDateTime.prototype.microsecond

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

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

5.3.13 get Temporal.PlainDateTime.prototype.nanosecond

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

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

5.3.14 get Temporal.PlainDateTime.prototype.dayOfWeek

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

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

5.3.15 get Temporal.PlainDateTime.prototype.dayOfYear

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

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

5.3.16 get Temporal.PlainDateTime.prototype.weekOfYear

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

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

5.3.17 get Temporal.PlainDateTime.prototype.daysInWeek

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

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

5.3.18 get Temporal.PlainDateTime.prototype.daysInMonth

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

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

5.3.19 get Temporal.PlainDateTime.prototype.daysInYear

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

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

5.3.20 get Temporal.PlainDateTime.prototype.monthsInYear

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

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

5.3.21 get Temporal.PlainDateTime.prototype.inLeapYear

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

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

5.3.22 Temporal.PlainDateTime.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. If Type(temporalDateTimeLike) is not Object, then
    1. Throw a TypeError exception.
  4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateTimeLike).
  5. Let calendar be dateTime.[[Calendar]].
  6. Let fieldNames be ? CalendarFields(calendar, « "day", "hour", "microsecond", "millisecond", "minute", "month", "monthCode", "nanosecond", "second", "year" »).
  7. Let partialDateTime be ? PreparePartialTemporalFields(temporalDateTimeLike, fieldNames).
  8. Set options to ? GetOptionsObject(options).
  9. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
  10. Set fields to ? CalendarMergeFields(calendar, fields, partialDateTime).
  11. Set fields to ? PrepareTemporalFields(fields, fieldNames, «»).
  12. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
  13. Assert: ! IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  14. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  15. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar).

5.3.23 Temporal.PlainDateTime.prototype.withPlainTime ( [ plainTimeLike ] )

The withPlainTime method takes one argument plainTimeLike. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. If plainTimeLike is undefined, then
    1. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], 0, 0, 0, 0, 0, 0, dateTime.[[Calendar]]).
  4. Let plainTime be ? ToTemporalTime(plainTimeLike).
  5. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], plainTime.[[ISOHour]], plainTime.[[ISOMinute]], plainTime.[[ISOSecond]], plainTime.[[ISOMillisecond]], plainTime.[[ISOMicrosecond]], plainTime.[[ISONanosecond]], dateTime.[[Calendar]]).

5.3.24 Temporal.PlainDateTime.prototype.withPlainDate ( plainDateLike )

The withPlainDate method takes one argument plainDateLike. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let plainDate be ? ToTemporalDate(plainDateLike).
  4. Let calendar be ? ConsolidateCalendars(dateTime.[[Calendar]], plainDate.[[Calendar]]).
  5. Return ? CreateTemporalDateTime(plainDate.[[ISOYear]], plainDate.[[ISOMonth]], plainDate.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], calendar).

5.3.25 Temporal.PlainDateTime.prototype.withCalendar ( calendar )

The withCalendar method takes one argument calendar. The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be ? ToTemporalCalendar(calendar).
  4. Return ? CreateTemporalDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], calendar).

5.3.26 Temporal.PlainDateTime.prototype.add ( temporalDurationLike [ , options ] )

The add 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. Set options to ? GetOptionsObject(options).
  5. Let result be ? AddDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], options).
  6. Assert: ! IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  7. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  8. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], dateTime.[[Calendar]]).

5.3.27 Temporal.PlainDateTime.prototype.subtract ( temporalDurationLike [ , options ] )

The subtract 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. Set options to ? GetOptionsObject(options).
  5. Let result be ? AddDateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], −duration.[[Years]], −duration.[[Months]], −duration.[[Weeks]], −duration.[[Days]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]], options).
  6. Assert: ! IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
  7. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
  8. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], dateTime.[[Calendar]]).

5.3.28 Temporal.PlainDateTime.prototype.until ( other [ , options ] )

The until 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. Set other to ? ToTemporalDateTime(other).
  4. If ? CalendarEquals(dateTime.[[Calendar]], other.[[Calendar]]) is false, throw a RangeError exception.
  5. Set options to ? GetOptionsObject(options).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(options, « », "nanosecond").
  7. Let defaultLargestUnit be ! LargerOfTwoTemporalUnits("day", smallestUnit).
  8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit).
  9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  10. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  11. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  12. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  13. Let diff be ? DifferenceISODateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], other.[[ISOYear]], other.[[ISOMonth]], other.[[ISODay]], other.[[ISOHour]], other.[[ISOMinute]], other.[[ISOSecond]], other.[[ISOMillisecond]], other.[[ISOMicrosecond]], other.[[ISONanosecond]], dateTime.[[Calendar]], largestUnit, options).
  14. Let relativeTo be ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
  15. Let roundResult be ? RoundDuration(diff.[[Years]], diff.[[Months]], diff.[[Weeks]], diff.[[Days]], diff.[[Hours]], diff.[[Minutes]], diff.[[Seconds]], diff.[[Milliseconds]], diff.[[Microseconds]], diff.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, relativeTo).
  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.29 Temporal.PlainDateTime.prototype.since ( other [ , options ] )

The since 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. Set other to ? ToTemporalDateTime(other).
  4. If ? CalendarEquals(dateTime.[[Calendar]], other.[[Calendar]]) is false, throw a RangeError exception.
  5. Set options to ? GetOptionsObject(options).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(options, « », "nanosecond").
  7. Let defaultLargestUnit be ! LargerOfTwoTemporalUnits("day", smallestUnit).
  8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit).
  9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  10. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  11. Set roundingMode to ! NegateTemporalRoundingMode(roundingMode).
  12. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  13. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  14. Let diff be ? DifferenceISODateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], other.[[ISOYear]], other.[[ISOMonth]], other.[[ISODay]], other.[[ISOHour]], other.[[ISOMinute]], other.[[ISOSecond]], other.[[ISOMillisecond]], other.[[ISOMicrosecond]], other.[[ISONanosecond]], dateTime.[[Calendar]], largestUnit, options).
  15. Let relativeTo be ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
  16. Let roundResult be ? RoundDuration(diff.[[Years]], diff.[[Months]], diff.[[Weeks]], diff.[[Days]], diff.[[Hours]], diff.[[Minutes]], diff.[[Seconds]], diff.[[Milliseconds]], diff.[[Microseconds]], diff.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, relativeTo).
  17. Let result be ! BalanceDuration(roundResult.[[Days]], roundResult.[[Hours]], roundResult.[[Minutes]], roundResult.[[Seconds]], roundResult.[[Milliseconds]], roundResult.[[Microseconds]], roundResult.[[Nanoseconds]], largestUnit).
  18. Return ? CreateTemporalDuration(−roundResult.[[Years]], −roundResult.[[Months]], −roundResult.[[Weeks]], −result.[[Days]], −result.[[Hours]], −result.[[Minutes]], −result.[[Seconds]], −result.[[Milliseconds]], −result.[[Microseconds]], −result.[[Nanoseconds]]).

5.3.30 Temporal.PlainDateTime.prototype.round ( roundTo )

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

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. If roundTo is undefined, then
    1. Throw a TypeError exception.
  4. If Type(roundTo) is String, then
    1. Let paramString be roundTo.
    2. Set roundTo to ! OrdinaryObjectCreate(null).
    3. Perform ! CreateDataPropertyOrThrow(roundTo, "_smallestUnit_", paramString).
  5. Else,
    1. Set roundTo to ? GetOptionsObject(roundTo).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(roundTo, « "year", "month", "week" », undefined).
  7. If smallestUnit is undefined, throw a RangeError exception.
  8. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand").
  9. Let roundingIncrement be ? ToTemporalDateTimeRoundingIncrement(roundTo, smallestUnit).
  10. Let result be ! RoundISODateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode).
  11. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], dateTime.[[Calendar]]).

5.3.31 Temporal.PlainDateTime.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. Set other to ? ToTemporalDateTime(other).
  4. Let result be ! CompareISODateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], other.[[ISOYear]], other.[[ISOMonth]], other.[[ISODay]], other.[[ISOHour]], other.[[ISOMinute]], other.[[ISOSecond]], other.[[ISOMillisecond]], other.[[ISOMicrosecond]], other.[[ISONanosecond]]).
  5. If result is not 0, return false.
  6. Return ? CalendarEquals(dateTime.[[Calendar]], other.[[Calendar]]).

5.3.32 Temporal.PlainDateTime.prototype.toString ( [ options ] )

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

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Set options to ? GetOptionsObject(options).
  4. Let precision be ? ToSecondsStringPrecision(options).
  5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  6. Let showCalendar be ? ToShowCalendarOption(options).
  7. Let result be ! RoundISODateTime(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], precision.[[Increment]], precision.[[Unit]], roundingMode).
  8. Return ? TemporalDateTimeToString(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], dateTime.[[Calendar]], precision.[[Precision]], showCalendar).

5.3.33 Temporal.PlainDateTime.prototype.toLocaleString ( [ locales [ , options ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Temporal.PlainDateTime.prototype.toLocaleString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString method is used.

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. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto").

5.3.34 Temporal.PlainDateTime.prototype.toJSON ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto").

5.3.35 Temporal.PlainDateTime.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

5.3.36 Temporal.PlainDateTime.prototype.toZonedDateTime ( temporalTimeZoneLike [ , options ] )

The toZonedDateTime 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. Set options to ? GetOptionsObject(options).
  5. Let disambiguation be ? ToTemporalDisambiguation(options).
  6. Let instant be ? BuiltinTimeZoneGetInstantFor(timeZone, dateTime, disambiguation).
  7. Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, dateTime.[[Calendar]]).

5.3.37 Temporal.PlainDateTime.prototype.toPlainDate ( )

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]], dateTime.[[Calendar]]).

5.3.38 Temporal.PlainDateTime.prototype.toPlainYearMonth ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let fieldNames be ? CalendarFields(calendar, « "monthCode", "year" »).
  5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
  6. Return ? YearMonthFromFields(calendar, fields).

5.3.39 Temporal.PlainDateTime.prototype.toPlainMonthDay ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let calendar be dateTime.[[Calendar]].
  4. Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »).
  5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
  6. Return ? MonthDayFromFields(calendar, fields).

5.3.40 Temporal.PlainDateTime.prototype.toPlainTime ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Return ? CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).

5.3.41 Temporal.PlainDateTime.prototype.getISOFields ( )

The following steps are taken:

  1. Let dateTime be the this value.
  2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
  3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%).
  4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", dateTime.[[Calendar]]).
  5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(dateTime.[[ISODay]])).
  6. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(dateTime.[[ISOHour]])).
  7. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(dateTime.[[ISOMicrosecond]])).
  8. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(dateTime.[[ISOMillisecond]])).
  9. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(dateTime.[[ISOMinute]])).
  10. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(dateTime.[[ISOMonth]])).
  11. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(dateTime.[[ISONanosecond]])).
  12. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(dateTime.[[ISOSecond]])).
  13. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(dateTime.[[ISOYear]])).
  14. Return fields.

5.4 Properties of Temporal.PlainDateTime Instances

Temporal.PlainDateTime instances are ordinary objects that inherit properties from the %Temporal.PlainDateTime.prototype% intrinsic object. Temporal.PlainDateTime instances are initially created with the internal slots described in Table 4.

Table 4: Internal Slots of Temporal.PlainDateTime Instances
Internal Slot Description
[[InitializedTemporalDateTime]] The only specified use of this slot is for distinguishing Temporal.PlainDateTime instances from other objects.
[[ISOYear]] An integer representing the year in the ISO 8601 calendar.
[[ISOMonth]] An integer between 1 and 12, inclusive, representing the month of the year in the ISO 8601 calendar.
[[ISODay]] An integer between 1 and ISODaysInMonth([[ISOYear]], [[ISOMonth]]), inclusive, representing the day of the month in the ISO 8601 calendar.
[[ISOHour]] An integer between 0 and 23, inclusive, representing the hour of the day.
[[ISOMinute]] An integer between 0 and 59, inclusive, representing the minute of the hour.
[[ISOSecond]] An integer between 0 and 59, inclusive, representing the second within the minute.
[[ISOMillisecond]] An integer between 0 and 999, inclusive, representing the millisecond within the second.
[[ISOMicrosecond]] An integer between 0 and 999, inclusive, representing the microsecond within the millisecond.
[[ISONanosecond]] An integer between 0 and 999, inclusive, representing the nanosecond within the microsecond.
[[Calendar]] An Object representing the calendar.

5.5 Abstract operations

5.5.1 GetEpochFromISOParts ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Assert: ! IsValidISODate(year, month, day) is true.
  3. Assert: ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is true.
  4. Let date be ! MakeDay(𝔽(year), 𝔽(month − 1), 𝔽(day)).
  5. Let time be ! MakeTime(𝔽(hour), 𝔽(minute), 𝔽(second), 𝔽(millisecond)).
  6. Let ms be ! MakeDate(date, time).
  7. Assert: ms is finite.
  8. Return (ms) × 106 + microsecond × 103 + nanosecond.

5.5.2 ISODateTimeWithinLimits ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

Note

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

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Let ns be ! GetEpochFromISOParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond).
  3. If ns ≤ -8.64 × 1021 - 8.64 × 1013, then
    1. Return false.
  4. If ns ≥ 8.64 × 1021 + 8.64 × 1013, then
    1. Return false.
  5. Return true.

5.5.3 InterpretTemporalDateTimeFields ( calendar, fields, options )

The abstract operation InterpretTemporalDateTimeFields interprets the date/time fields in the object fields using the given calendar, and returns a Record with the fields according to the ISO calendar.

  1. Let timeResult be ? ToTemporalTimeRecord(fields).
  2. Let overflow be ? ToTemporalOverflow(options).
  3. Let temporalDate be ? DateFromFields(calendar, fields, options).
  4. Let timeResult be ? RegulateTime(timeResult.[[Hour]], timeResult.[[Minute]], timeResult.[[Second]], timeResult.[[Millisecond]], timeResult.[[Microsecond]], timeResult.[[Nanosecond]], overflow).
  5. Return the Record { [[Year]]: temporalDate.[[ISOYear]], [[Month]]: temporalDate.[[ISOMonth]], [[Day]]: temporalDate.[[ISODay]], [[Hour]]: timeResult.[[Hour]], [[Minute]]: timeResult.[[Minute]], [[Second]]: timeResult.[[Second]], [[Millisecond]]: timeResult.[[Millisecond]], [[Microsecond]]: timeResult.[[Microsecond]], [[Nanosecond]]: timeResult.[[Nanosecond]] }.

5.5.4 ToTemporalDateTime ( item [ , options ] )

The abstract operation ToTemporalDateTime returns its argument item if it is already a Temporal.PlainDateTime instance, converts item to a new Temporal.PlainDateTime instance if possible, and throws otherwise.

  1. If options is not present, set options to ! OrdinaryObjectCreate(null).
  2. If Type(item) is Object, then
    1. If item has an [[InitializedTemporalDateTime]] internal slot, then
      1. Return item.
    2. If item has an [[InitializedTemporalZonedDateTime]] internal slot, then
      1. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
      2. Return ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
    3. If item has an [[InitializedTemporalDate]] internal slot, then
      1. Return ? CreateTemporalDateTime(item.[[ISOYear]], item.[[ISOMonth]], item.[[ISODay]], 0, 0, 0, 0, 0, 0, item.[[Calendar]]).
    4. Let calendar be ? GetTemporalCalendarWithISODefault(item).
    5. Let fieldNames be ? CalendarFields(calendar, « "day", "hour", "microsecond", "millisecond", "minute", "month", "monthCode", "nanosecond", "second", "year" »).
    6. Let fields be ? PrepareTemporalFields(item, fieldNames, «»).
    7. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
  3. Else,
    1. Perform ? ToTemporalOverflow(options).
    2. Let string be ? ToString(item).
    3. Let result be ? ParseTemporalDateTimeString(string).
    4. Assert: ! IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
    5. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
    6. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
  4. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar).

5.5.5 BalanceISODateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Let balancedTime be ! BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond).
  3. Let balancedDate be ! BalanceISODate(year, month, day + balancedTime.[[Days]]).
  4. 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.5.6 CreateTemporalDateTime ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar [ , newTarget ] )

  1. Assert: isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Assert: Type(calendar) is Object.
  3. If ! IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception.
  4. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
  5. If ! ISODateTimeWithinLimits(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond) is false, then
    1. Throw a RangeError exception.
  6. If newTarget is not present, set it to %Temporal.PlainDateTime%.
  7. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainDateTime.prototype%", « [[InitializedTemporalDateTime]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[ISOHour]], [[ISOMinute]], [[ISOSecond]], [[ISOMillisecond]], [[ISOMicrosecond]], [[ISONanosecond]], [[Calendar]] »).
  8. Set object.[[ISOYear]] to isoYear.
  9. Set object.[[ISOMonth]] to isoMonth.
  10. Set object.[[ISODay]] to isoDay.
  11. Set object.[[ISOHour]] to hour.
  12. Set object.[[ISOMinute]] to minute.
  13. Set object.[[ISOSecond]] to second.
  14. Set object.[[ISOMillisecond]] to millisecond.
  15. Set object.[[ISOMicrosecond]] to microsecond.
  16. Set object.[[ISONanosecond]] to nanosecond.
  17. Set object.[[Calendar]] to calendar.
  18. Return object.

5.5.7 TemporalDateTimeToString ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, precision, showCalendar )

  1. Assert: isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Let year be ! PadISOYear(isoYear).
  3. Let month be isoMonth formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  4. Let day be isoDay formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  5. Let hour be hour formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  6. Let minute be minute formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  7. Let seconds be ! FormatSecondsStringPart(second, millisecond, microsecond, nanosecond, precision).
  8. Let calendarID be ? ToString(calendar).
  9. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar).
  10. 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, seconds, and calendarString.

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

  1. Assert: y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, and ns2 are integers.
  2. Let dateResult be ! CompareISODate(y1, mon1, d1, y2, mon2, d2).
  3. If dateResult is not 0, then
    1. Return dateResult.
  4. Return ! CompareTemporalTime(h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2).

5.5.9 AddDateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, calendar, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, options )

The abstract operation AddDateTime adds a duration to a combined date and time, according to the reckoning of the given calendar.

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. Let timeResult be ! AddTime(hour, minute, second, millisecond, microsecond, nanosecond, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  3. Let datePart be ? CreateTemporalDate(year, month, day, calendar).
  4. Let dateDuration be ? CreateTemporalDuration(years, months, weeks, days + timeResult.[[Days]], 0, 0, 0, 0, 0, 0).
  5. Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
  6. Return the Record { [[Year]]: addedDate.[[ISOYear]], [[Month]]: addedDate.[[ISOMonth]], [[Day]]: addedDate.[[ISODay]], [[Hour]]: timeResult.[[Hour]], [[Minute]]: timeResult.[[Minute]], [[Second]]: timeResult.[[Second]], [[Millisecond]]: timeResult.[[Millisecond]], [[Microsecond]]: timeResult.[[Microsecond]], [[Nanosecond]]: timeResult.[[Nanosecond]] }.

5.5.10 RoundISODateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, roundingMode [ , dayLength ] )

The abstract operation RoundISODateTime rounds the time part of a combined date and time, carrying over any excess into the date part.

  1. Assert: year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
  2. If dayLength is not present, set dayLength to 8.64 × 1013.
  3. Let roundedTime be ! RoundTime(hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, roundingMode, dayLength).
  4. Let balanceResult be ! BalanceISODate(year, month, day + roundedTime.[[Days]]).
  5. Return the Record { [[Year]]: balanceResult.[[Year]], [[Month]]: balanceResult.[[Month]], [[Day]]: balanceResult.[[Day]], [[Hour]]: roundedTime.[[Hour]], [[Minute]]: roundedTime.[[Minute]], [[Second]]: roundedTime.[[Second]], [[Millisecond]]: roundedTime.[[Millisecond]], [[Microsecond]]: roundedTime.[[Microsecond]], [[Nanosecond]]: roundedTime.[[Nanosecond]] }.

5.5.11 DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, ns2, calendar, largestUnit [ , options ] )

The abstract operation DifferenceISODateTime returns a Record with the elapsed duration from a first date and time, until a second date and time, according to the reckoning of the given calendar. The given date and time units are all in the ISO 8601 calendar. The largestUnit and options arguments are used in calendar's dateUntil method.

  1. Assert: y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, and ns2 are integers.
  2. If options is not present, set options to ! OrdinaryObjectCreate(null).
  3. Let timeDifference be ! DifferenceTime(h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2).
  4. Let timeSign be ! DurationSign(0, 0, 0, timeDifference.[[Days]], timeDifference.[[Hours]], timeDifference.[[Minutes]], timeDifference.[[Seconds]], timeDifference.[[Milliseconds]], timeDifference.[[Microseconds]], timeDifference.[[Nanoseconds]]).
  5. Let dateSign be ! CompareISODate(y2, mon2, d2, y1, mon1, d1).
  6. Let balanceResult be ! BalanceISODate(y1, mon1, d1 + timeDifference.[[Days]]).
  7. If timeSign is -dateSign, then
    1. Set balanceResult to ! BalanceISODate(balanceResult.[[Year]], balanceResult.[[Month]], balanceResult.[[Day]] - timeSign).
    2. Set timeDifference to ? BalanceDuration(-timeSign, timeDifference.[[Hours]], timeDifference.[[Minutes]], timeDifference.[[Seconds]], timeDifference.[[Milliseconds]], timeDifference.[[Microseconds]], timeDifference.[[Nanoseconds]], largestUnit).
  8. Let date1 be ? CreateTemporalDate(balanceResult.[[Year]], balanceResult.[[Month]], balanceResult.[[Day]], calendar).
  9. Let date2 be ? CreateTemporalDate(y2, mon2, d2, calendar).
  10. Let dateLargestUnit be ! LargerOfTwoTemporalUnits("day", largestUnit).
  11. Let untilOptions be ? MergeLargestUnitOption(options, dateLargestUnit).
  12. Let dateDifference be ? CalendarDateUntil(calendar, date1, date2, untilOptions).
  13. Let balanceResult be ? BalanceDuration(dateDifference.[[Days]], timeDifference.[[Hours]], timeDifference.[[Minutes]], timeDifference.[[Seconds]], timeDifference.[[Milliseconds]], timeDifference.[[Microseconds]], timeDifference.[[Nanoseconds]], largestUnit).
  14. Return the Record { [[Years]]: dateDifference.[[Years]], [[Months]]: dateDifference.[[Months]], [[Weeks]]: dateDifference.[[Weeks]], [[Days]]: balanceResult.[[Days]], [[Hours]]: balanceResult.[[Hours]], [[Minutes]]: balanceResult.[[Minutes]], [[Seconds]]: balanceResult.[[Seconds]], [[Milliseconds]]: balanceResult.[[Milliseconds]], [[Microseconds]]: balanceResult.[[Microseconds]], [[Nanoseconds]]: balanceResult.[[Nanoseconds]] }.

6 Temporal.ZonedDateTime Objects

A Temporal.ZonedDateTime object is an Object referencing a fixed point in time with nanoseconds precision, and containing Object values corresponding to a particular time zone and calendar system.

6.1 The Temporal.ZonedDateTime Constructor

The Temporal.ZonedDateTime constructor:

  • creates and initializes a new Temporal.ZonedDateTime object when called as a constructor.
  • is not intended to be called as a function and will throw an exception when called in that manner.
  • may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.ZonedDateTime behaviour must include a super call to the %Temporal.ZonedDateTime% constructor to create and initialize subclass instances with the necessary internal slots.

6.1.1 Temporal.ZonedDateTime ( epochNanoseconds, timeZoneLike [ , calendarLike ] )

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

  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Set epochNanoseconds to ? ToBigInt(epochNanoseconds).
  3. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception.
  4. Let timeZone be ? ToTemporalTimeZone(timeZoneLike).
  5. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
  6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget).

6.2 Properties of the Temporal.ZonedDateTime Constructor

The value of the [[Prototype]] internal slot of the Temporal.ZonedDateTime constructor is the intrinsic object %Function.prototype%.

The Temporal.ZonedDateTime constructor has the following properties:

6.2.1 Temporal.ZonedDateTime.prototype

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

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

6.2.2 Temporal.ZonedDateTime.from ( item [ , options ] )

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

  1. Set options to ? GetOptionsObject(options).
  2. If Type(item) is Object and item has an [[InitializedTemporalZonedDateTime]] internal slot, then
    1. Perform ? ToTemporalOverflow(options).
    2. Perform ? ToTemporalDisambiguation(options).
    3. Perform ? ToTemporalOffset(options, "reject").
    4. Return ! CreateTemporalZonedDateTime(item.[[Nanoseconds]], item.[[TimeZone]], item.[[Calendar]]).
  3. Return ? ToTemporalZonedDateTime(item, options).

6.2.3 Temporal.ZonedDateTime.compare ( one, two )

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

  1. Set one to ? ToTemporalZonedDateTime(one).
  2. Set two to ? ToTemporalZonedDateTime(two).
  3. Return 𝔽(! CompareEpochNanoseconds(one.[[Nanoseconds]], two.[[Nanoseconds]])).

6.3 Properties of the Temporal.ZonedDateTime Prototype Object

The Temporal.ZonedDateTime prototype object

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

6.3.1 Temporal.ZonedDateTime.prototype.constructor

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

6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ]

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

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

6.3.3 get Temporal.ZonedDateTime.prototype.calendar

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

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

6.3.4 get Temporal.ZonedDateTime.prototype.timeZone

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Return zonedDateTime.[[TimeZone]].

6.3.5 get Temporal.ZonedDateTime.prototype.year

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarYear(calendar, temporalDateTime).

6.3.6 get Temporal.ZonedDateTime.prototype.month

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarMonth(calendar, temporalDateTime).

6.3.7 get Temporal.ZonedDateTime.prototype.monthCode

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarMonthCode(calendar, temporalDateTime).

6.3.8 get Temporal.ZonedDateTime.prototype.day

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarDay(calendar, temporalDateTime).

6.3.9 get Temporal.ZonedDateTime.prototype.hour

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return 𝔽(temporalDateTime.[[ISOHour]]).

6.3.10 get Temporal.ZonedDateTime.prototype.minute

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return 𝔽(temporalDateTime.[[ISOMinute]]).

6.3.11 get Temporal.ZonedDateTime.prototype.second

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return 𝔽(temporalDateTime.[[ISOSecond]]).

6.3.12 get Temporal.ZonedDateTime.prototype.millisecond

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return 𝔽(temporalDateTime.[[ISOMillisecond]]).

6.3.13 get Temporal.ZonedDateTime.prototype.microsecond

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return 𝔽(temporalDateTime.[[ISOMicrosecond]]).

6.3.14 get Temporal.ZonedDateTime.prototype.nanosecond

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return 𝔽(temporalDateTime.[[ISONanosecond]]).

6.3.15 get Temporal.ZonedDateTime.prototype.epochSeconds

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let ns be zonedDateTime.[[Nanoseconds]].
  4. Let s be RoundTowardsZero((ns) / 109).
  5. Return 𝔽(s).

6.3.16 get Temporal.ZonedDateTime.prototype.epochMilliseconds

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let ns be zonedDateTime.[[Nanoseconds]].
  4. Let ms be RoundTowardsZero((ns) / 106).
  5. Return 𝔽(ms).

6.3.17 get Temporal.ZonedDateTime.prototype.epochMicroseconds

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let ns be zonedDateTime.[[Nanoseconds]].
  4. Let µs be RoundTowardsZero((ns) / 103).
  5. Return ℤ(µs).

6.3.18 get Temporal.ZonedDateTime.prototype.epochNanoseconds

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

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

6.3.19 get Temporal.ZonedDateTime.prototype.dayOfWeek

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarDayOfWeek(calendar, temporalDateTime).

6.3.20 get Temporal.ZonedDateTime.prototype.dayOfYear

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarDayOfYear(calendar, temporalDateTime).

6.3.21 get Temporal.ZonedDateTime.prototype.weekOfYear

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarWeekOfYear(calendar, temporalDateTime).

6.3.22 get Temporal.ZonedDateTime.prototype.hoursInDay

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let isoCalendar be ! GetISO8601Calendar().
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, isoCalendar).
  7. Let year be temporalDateTime.[[ISOYear]].
  8. Let month be temporalDateTime.[[ISOMonth]].
  9. Let day be temporalDateTime.[[ISODay]].
  10. Let today be ? CreateTemporalDateTime(year, month, day, 0, 0, 0, 0, 0, 0, isoCalendar).
  11. Let tomorrowFields be ? AddISODate(year, month, day, 0, 0, 0, 1, "reject").
  12. Let tomorrow be ? CreateTemporalDateTime(tomorrowFields.[[Year]], tomorrowFields.[[Month]], tomorrowFields.[[Day]], 0, 0, 0, 0, 0, 0, isoCalendar).
  13. Let todayInstant be ? BuiltinTimeZoneGetInstantFor(timeZone, today, "compatible").
  14. Let tomorrowInstant be ? BuiltinTimeZoneGetInstantFor(timeZone, tomorrow, "compatible").
  15. Let diffNs be tomorrowInstant.[[Nanoseconds]] − todayInstant.[[Nanoseconds]].
  16. Return 𝔽(diffNs / (3.6 × 1012)).

6.3.23 get Temporal.ZonedDateTime.prototype.daysInWeek

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarDaysInWeek(calendar, temporalDateTime).

6.3.24 get Temporal.ZonedDateTime.prototype.daysInMonth

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarDaysInMonth(calendar, temporalDateTime).

6.3.25 get Temporal.ZonedDateTime.prototype.daysInYear

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarDaysInYear(calendar, temporalDateTime).

6.3.26 get Temporal.ZonedDateTime.prototype.monthsInYear

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarMonthsInYear(calendar, temporalDateTime).

6.3.27 get Temporal.ZonedDateTime.prototype.inLeapYear

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CalendarInLeapYear(calendar, temporalDateTime).

6.3.28 get Temporal.ZonedDateTime.prototype.offsetNanoseconds

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Return 𝔽(? GetOffsetNanosecondsFor(timeZone, instant)).

6.3.29 get Temporal.ZonedDateTime.prototype.offset

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  4. Return ? BuiltinTimeZoneGetOffsetStringFor(zonedDateTime.[[TimeZone]], instant).

6.3.30 Temporal.ZonedDateTime.prototype.with ( temporalZonedDateTimeLike [ , options ] )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. If Type(temporalZonedDateTimeLike) is not Object, then
    1. Throw a TypeError exception.
  4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalZonedDateTimeLike).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let fieldNames be ? CalendarFields(calendar, « "day", "hour", "microsecond", "millisecond", "minute", "month", "monthCode", "nanosecond", "second", "year" »).
  7. Append "offset" to fieldNames.
  8. Let partialZonedDateTime be ? PreparePartialTemporalFields(temporalZonedDateTimeLike, fieldNames).
  9. Set options to ? GetOptionsObject(options).
  10. Let disambiguation be ? ToTemporalDisambiguation(options).
  11. Let offset be ? ToTemporalOffset(options, "prefer").
  12. Let timeZone be zonedDateTime.[[TimeZone]].
  13. Append "timeZone" to fieldNames.
  14. Let fields be ? PrepareTemporalFields(zonedDateTime, fieldNames, « "timeZone", "offset" »).
  15. Set fields to ? CalendarMergeFields(calendar, fields, partialZonedDateTime).
  16. Set fields to ? PrepareTemporalFields(fields, fieldNames, « "timeZone", "offset" »).
  17. Let offsetString be ! Get(fields, "offset").
  18. Assert: Type(offsetString) is String.
  19. Let dateTimeResult be ? InterpretTemporalDateTimeFields(calendar, fields, options).
  20. Let offsetNanoseconds be ? ParseTimeZoneOffsetString(offsetString).
  21. Let epochNanoseconds be ? InterpretISODateTimeOffset(dateTimeResult.[[Year]], dateTimeResult.[[Month]], dateTimeResult.[[Day]], dateTimeResult.[[Hour]], dateTimeResult.[[Minute]], dateTimeResult.[[Second]], dateTimeResult.[[Millisecond]], dateTimeResult.[[Microsecond]], dateTimeResult.[[Nanosecond]], option, offsetNanoseconds, timeZone, disambiguation, offset, match exactly).
  22. Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).

6.3.31 Temporal.ZonedDateTime.prototype.withPlainTime ( [ plainTimeLike ] )

The withPlainTime method takes one argument plainTimeLike. The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. If plainTimeLike is undefined, then
    1. Let plainTime be ? CreateTemporalTime(0, 0, 0, 0, 0, 0).
  4. Else,
    1. Let plainTime be ? ToTemporalTime(plainTimeLike).
  5. Let timeZone be zonedDateTime.[[TimeZone]].
  6. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  7. Let calendar be zonedDateTime.[[Calendar]].
  8. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  9. Let resultPlainDateTime be ? CreateTemporalDateTime(plainDateTime.[[ISOYear]], plainDateTime.[[ISOMonth]], plainDateTime.[[ISODay]], plainTime.[[ISOHour]], plainTime.[[ISOMinute]], plainTime.[[ISOSecond]], plainTime.[[ISOMillisecond]], plainTime.[[ISOMicrosecond]], plainTime.[[ISONanosecond]], calendar).
  10. Set instant to ? BuiltinTimeZoneGetInstantFor(timeZone, resultPlainDateTime, "compatible").
  11. Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar).

6.3.32 Temporal.ZonedDateTime.prototype.withPlainDate ( plainDateLike )

The withPlainDate method takes one argument plainDateLike. The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let plainDate be ? ToTemporalDate(plainDateLike).
  4. Let timeZone be zonedDateTime.[[TimeZone]].
  5. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  6. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).
  7. Let calendar be ? ConsolidateCalendars(zonedDateTime.[[Calendar]], plainDate.[[Calendar]]).
  8. Let resultPlainDateTime be ? CreateTemporalDateTime(plainDate.[[ISOYear]], plainDate.[[ISOMonth]], plainDate.[[ISODay]], plainDateTime.[[ISOHour]], plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]], plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]], plainDateTime.[[ISONanosecond]], calendar).
  9. Set instant to ? BuiltinTimeZoneGetInstantFor(timeZone, resultPlainDateTime, "compatible").
  10. Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar).

6.3.33 Temporal.ZonedDateTime.prototype.withTimeZone ( timeZoneLike )

The withTimeZone method takes one argument timeZoneLike. The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be ? ToTemporalTimeZone(timeZoneLike).
  4. Return ! CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]], timeZone, zonedDateTime.[[Calendar]]).

6.3.34 Temporal.ZonedDateTime.prototype.withCalendar ( calendarLike )

The withCalendar method takes one argument calendarLike. The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let calendar be ? ToTemporalCalendar(calendarLike).
  4. Return ! CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]], zonedDateTime.[[TimeZone]], calendar).

6.3.35 Temporal.ZonedDateTime.prototype.add ( temporalDurationLike [ , options ] )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Set options to ? GetOptionsObject(options).
  5. Let timeZone be zonedDateTime.[[TimeZone]].
  6. Let calendar be zonedDateTime.[[Calendar]].
  7. Let epochNanoseconds be ? AddZonedDateTime(zonedDateTime.[[Nanoseconds]], timeZone, calendar, duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], options).
  8. Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).

6.3.36 Temporal.ZonedDateTime.prototype.subtract ( temporalDurationLike [ , options ] )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, « »).
  4. Set options to ? GetOptionsObject(options).
  5. Let timeZone be zonedDateTime.[[TimeZone]].
  6. Let calendar be zonedDateTime.[[Calendar]].
  7. Let epochNanoseconds be ? AddZonedDateTime(zonedDateTime.[[Nanoseconds]], timeZone, calendar, −duration.[[Years]], −duration.[[Months]], −duration.[[Weeks]], −duration.[[Days]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]], options).
  8. Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).

6.3.37 Temporal.ZonedDateTime.prototype.until ( other [ , options ] )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Set other to ? ToTemporalZonedDateTime(other).
  4. If ? CalendarEquals(zonedDateTime.[[Calendar]], other.[[Calendar]]) is false, then
    1. Throw a RangeError exception.
  5. Set options to ? GetOptionsObject(options).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(options, « », "nanosecond").
  7. Let defaultLargestUnit be ! LargerOfTwoTemporalUnits("hour", smallestUnit).
  8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit).
  9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  10. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  11. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  12. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  13. If largestUnit is not one of "year", "month", "week", or "day", then
    1. Let differenceNs be ! DifferenceInstant(zonedDateTime.[[Nanoseconds]], other.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode).
    2. Let balanceResult be ! BalanceDuration(0, 0, 0, 0, 0, 0, differenceNs, largestUnit).
    3. Return ? CreateTemporalDuration(0, 0, 0, 0, balanceResult.[[Hours]], balanceResult.[[Minutes]], balanceResult.[[Seconds]], balanceResult.[[Milliseconds]], balanceResult.[[Microseconds]], balanceResult.[[Nanoseconds]]).
  14. If ? TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, then
    1. Throw a RangeError exception.
  15. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
  16. Let difference be ? DifferenceZonedDateTime(zonedDateTime.[[Nanoseconds]], other.[[Nanoseconds]], zonedDateTime.[[TimeZone]], zonedDateTime.[[Calendar]], largestUnit, untilOptions).
  17. Let roundResult be ? RoundDuration(difference.[[Years]], difference.[[Months]], difference.[[Weeks]], difference.[[Days]], difference.[[Hours]], difference.[[Minutes]], difference.[[Seconds]], difference.[[Milliseconds]], difference.[[Microseconds]], difference.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, zonedDateTime).
  18. Let result be ? AdjustRoundedDurationDays(roundResult.[[Years]], roundResult.[[Months]], roundResult.[[Weeks]], roundResult.[[Days]], roundResult.[[Hours]], roundResult.[[Minutes]], roundResult.[[Seconds]], roundResult.[[Milliseconds]], roundResult.[[Microseconds]], roundResult.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, zonedDateTime).
  19. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

6.3.38 Temporal.ZonedDateTime.prototype.since ( other [ , options ] )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Set other to ? ToTemporalZonedDateTime(other).
  4. If ? CalendarEquals(zonedDateTime.[[Calendar]], other.[[Calendar]]) is false, then
    1. Throw a RangeError exception.
  5. Set options to ? GetOptionsObject(options).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(options, « », "nanosecond").
  7. Let defaultLargestUnit be ! LargerOfTwoTemporalUnits("hour", smallestUnit).
  8. Let largestUnit be ? ToLargestTemporalUnit(options, « », "auto", defaultLargestUnit).
  9. Perform ? ValidateTemporalUnitRange(largestUnit, smallestUnit).
  10. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  11. Set roundingMode to ! NegateTemporalRoundingMode(roundingMode).
  12. Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
  13. Let roundingIncrement be ? ToTemporalRoundingIncrement(options, maximum, false).
  14. If largestUnit is not one of "year", "month", "week", or "day", then
    1. Let differenceNs be ! DifferenceInstant(zonedDateTime.[[Nanoseconds]], other.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode).
    2. Let balanceResult be ! BalanceDuration(0, 0, 0, 0, 0, 0, differenceNs, largestUnit).
    3. Return ? CreateTemporalDuration(0, 0, 0, 0, −balanceResult.[[Hours]], −balanceResult.[[Minutes]], −balanceResult.[[Seconds]], −balanceResult.[[Milliseconds]], −balanceResult.[[Microseconds]], −balanceResult.[[Nanoseconds]]).
  15. If ? TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, then
    1. Throw a RangeError exception.
  16. Let untilOptions be ? MergeLargestUnitOption(options, largestUnit).
  17. Let difference be ? DifferenceZonedDateTime(zonedDateTime.[[Nanoseconds]], other.[[Nanoseconds]], zonedDateTime.[[TimeZone]], zonedDateTime.[[Calendar]], largestUnit, untilOptions).
  18. Let roundResult be ? RoundDuration(difference.[[Years]], difference.[[Months]], difference.[[Weeks]], difference.[[Days]], difference.[[Hours]], difference.[[Minutes]], difference.[[Seconds]], difference.[[Milliseconds]], difference.[[Microseconds]], difference.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, zonedDateTime).
  19. Let result be ? AdjustRoundedDurationDays(roundResult.[[Years]], roundResult.[[Months]], roundResult.[[Weeks]], roundResult.[[Days]], roundResult.[[Hours]], roundResult.[[Minutes]], roundResult.[[Seconds]], roundResult.[[Milliseconds]], roundResult.[[Microseconds]], roundResult.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode, zonedDateTime).
  20. Return ? CreateTemporalDuration(−result.[[Years]], −result.[[Months]], −result.[[Weeks]], −result.[[Days]], −result.[[Hours]], −result.[[Minutes]], −result.[[Seconds]], −result.[[Milliseconds]], −result.[[Microseconds]], −result.[[Nanoseconds]]).

6.3.39 Temporal.ZonedDateTime.prototype.round ( roundTo )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. If roundTo is undefined, then
    1. Throw a TypeError exception.
  4. If Type(roundTo) is String, then
    1. Let paramString be roundTo.
    2. Set roundTo to ! OrdinaryObjectCreate(null).
    3. Perform ! CreateDataPropertyOrThrow(roundTo, "_smallestUnit_", paramString).
  5. Else,
    1. Set roundTo to ? GetOptionsObject(roundTo).
  6. Let smallestUnit be ? ToSmallestTemporalUnit(roundTo, « "year", "month", "week" », undefined).
  7. If smallestUnit is undefined, throw a RangeError exception.
  8. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand").
  9. Let roundingIncrement be ? ToTemporalDateTimeRoundingIncrement(roundTo, smallestUnit).
  10. Let timeZone be zonedDateTime.[[TimeZone]].
  11. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  12. Let calendar be zonedDateTime.[[Calendar]].
  13. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  14. Let isoCalendar be ! GetISO8601Calendar().
  15. Let dtStart be ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], 0, 0, 0, 0, 0, 0, isoCalendar).
  16. Let instantStart be ? BuiltinTimeZoneGetInstantFor(timeZone, dtStart, "compatible").
  17. Let startNs be instantStart.[[Nanoseconds]].
  18. Let endNs be ? AddZonedDateTime(startNs, timeZone, zonedDateTime.[[Calendar]], 0, 0, 0, 1, 0, 0, 0, 0, 0, 0).
  19. Let dayLengthNs be (endNsstartNs).
  20. If dayLengthNs is 0, then
    1. Throw a RangeError exception.
  21. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode, dayLengthNs).
  22. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
  23. Let epochNanoseconds be ? InterpretISODateTimeOffset(roundResult.[[Year]], roundResult.[[Month]], roundResult.[[Day]], roundResult.[[Hour]], roundResult.[[Minute]], roundResult.[[Second]], roundResult.[[Millisecond]], roundResult.[[Microsecond]], roundResult.[[Nanosecond]], option, offsetNanoseconds, timeZone, "compatible", "prefer", match exactly).
  24. Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).

6.3.40 Temporal.ZonedDateTime.prototype.equals ( other )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Set other to ? ToTemporalZonedDateTime(other).
  4. If zonedDateTime.[[Nanoseconds]] ≠ other.[[Nanoseconds]], return false.
  5. If ? TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, return false.
  6. Return ? CalendarEquals(zonedDateTime.[[Calendar]], other.[[Calendar]]).

6.3.41 Temporal.ZonedDateTime.prototype.toString ( [ options ] )

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Set options to ? GetOptionsObject(options).
  4. Let precision be ? ToSecondsStringPrecision(options).
  5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
  6. Let showCalendar be ? ToShowCalendarOption(options).
  7. Let showTimeZone be ? ToShowTimeZoneNameOption(options).
  8. Let showOffset be ? ToShowOffsetOption(options).
  9. Return ? TemporalZonedDateTimeToString(zonedDateTime, precision.[[Precision]], showCalendar, showTimeZone, showOffset, precision.[[Increment]], precision.[[Unit]], roundingMode).

6.3.42 Temporal.ZonedDateTime.prototype.toLocaleString ( [ locales [ , options ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Temporal.ZonedDateTime.prototype.toLocaleString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString method is used.

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

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").

6.3.43 Temporal.ZonedDateTime.prototype.toJSON ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").

6.3.44 Temporal.ZonedDateTime.prototype.valueOf ( )

The following steps are taken:

  1. Throw a TypeError exception.

6.3.45 Temporal.ZonedDateTime.prototype.startOfDay ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let calendar be zonedDateTime.[[Calendar]].
  5. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Let startDateTime be ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], 0, 0, 0, 0, 0, 0, calendar).
  8. Let startInstant be ? BuiltinTimeZoneGetInstantFor(timeZone, startDateTime, "compatible").
  9. Return ! CreateTemporalZonedDateTime(startInstant.[[Nanoseconds]], timeZone, calendar).

6.3.46 Temporal.ZonedDateTime.prototype.toInstant ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).

6.3.47 Temporal.ZonedDateTime.prototype.toPlainDate ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CreateTemporalDate(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar).

6.3.48 Temporal.ZonedDateTime.prototype.toPlainTime ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Return ? CreateTemporalTime(temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]]).

6.3.49 Temporal.ZonedDateTime.prototype.toPlainDateTime ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).

6.3.50 Temporal.ZonedDateTime.prototype.toPlainYearMonth ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Let fieldNames be ? CalendarFields(calendar, « "monthCode", "year" »).
  8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
  9. Return ? YearMonthFromFields(calendar, fields).

6.3.51 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let timeZone be zonedDateTime.[[TimeZone]].
  4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  5. Let calendar be zonedDateTime.[[Calendar]].
  6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  7. Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »).
  8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
  9. Return ? MonthDayFromFields(calendar, fields).

6.3.52 Temporal.ZonedDateTime.prototype.getISOFields ( )

The following steps are taken:

  1. Let zonedDateTime be the this value.
  2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
  3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%).
  4. Let timeZone be zonedDateTime.[[TimeZone]].
  5. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
  6. Let calendar be zonedDateTime.[[Calendar]].
  7. Let dateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  8. Let offset be ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
  9. Perform ! CreateDataPropertyOrThrow(fields, "calendar", calendar).
  10. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", dateTime.[[ISODay]]).
  11. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", dateTime.[[ISOHour]]).
  12. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", dateTime.[[ISOMicrosecond]]).
  13. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", dateTime.[[ISOMillisecond]]).
  14. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", dateTime.[[ISOMinute]]).
  15. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", dateTime.[[ISOMonth]]).
  16. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", dateTime.[[ISONanosecond]]).
  17. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", dateTime.[[ISOSecond]]).
  18. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", dateTime.[[ISOYear]]).
  19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset).
  20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone).
  21. Return fields.

6.4 Properties of Temporal.ZonedDateTime Instances

Temporal.ZonedDateTime instances are ordinary objects that inherit properties from the %Temporal.ZonedDateTime.prototype% intrinsic object. Temporal.ZonedDateTime instances are initially created with the internal slots described in Table 5.

Table 5: Internal Slots of Temporal.ZonedDateTime Instances
Internal Slot Description
[[InitializedTemporalZonedDateTime]] The only specified use of this slot is for distinguishing Temporal.ZonedDateTime instances from other objects.
[[Nanoseconds]] A BigInt value representing the number of nanoseconds since the Unix epoch.
[[TimeZone]] An Object representing the time zone.
[[Calendar]] An Object representing the calendar.

6.5 Abstract operations

6.5.1 InterpretISODateTimeOffset ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, offsetBehaviour, offsetNanoseconds, timeZone, disambiguation, offsetOption, matchBehaviour )

The abstract operation InterpretISODateTimeOffset determines the exact time in timeZone corresponding to the given calendar date and time, and the given UTC offset in nanoseconds. In the case of more than one possible exact time, or no possible exact time, an answer is determined using offsetBehaviour (one of option, exact, or wall), disambiguation (one of "earlier", "later", "compatible", or "reject") and offsetOption (one of "ignore", "use", "prefer", or "reject").

As a special case when parsing ISO 8601 strings which are only required to specify time zone offsets to minutes precision, if matchBehaviour is match minutes, then a value for offsetNanoseconds that is rounded to the nearest minute will be accepted in those cases where offsetNanoseconds is compared against timeZone's offset. If matchBehaviour is match exactly, then this does not happen.

  1. Assert: offsetNanoseconds is an integer.
  2. Let calendar be ! GetISO8601Calendar().
  3. Let dateTime be ? CreateTemporalDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, calendar).
  4. If offsetBehaviour is wall, or offsetOption is "ignore", then
    1. Let instant be ? BuiltinTimeZoneGetInstantFor(timeZone, dateTime, disambiguation).
    2. Return instant.[[Nanoseconds]].
  5. If offsetBehaviour is exact, or offsetOption is "use", then
    1. Let epochNanoseconds be ! GetEpochFromISOParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond).
    2. Return epochNanosecondsoffsetNanoseconds.
  6. Assert: offsetBehaviour is option.
  7. Assert: offsetOption is "prefer" or "reject".
  8. Let possibleInstants be ? GetPossibleInstantsFor(timeZone, dateTime).
  9. For each element candidate of possibleInstants, do
    1. Let candidateNanoseconds be ? GetOffsetNanosecondsFor(timeZone, candidate).
    2. If candidateNanoseconds = offsetNanoseconds, then
      1. Return candidate.[[Nanoseconds]].
    3. If matchBehaviour is match minutes, then
      1. Let roundedCandidateNanoseconds be ! RoundNumberToIncrement(candidateNanoseconds, 60 × 109, "halfExpand").
      2. If roundedCandidateNanoseconds = offsetNanoseconds, then
        1. Return candidate.[[Nanoseconds]].
  10. If offsetOption is "reject", throw a RangeError exception.
  11. Let instant be ? DisambiguatePossibleInstants(possibleInstants, timeZone, dateTime, disambiguation).
  12. Return instant.[[Nanoseconds]].

6.5.2 ToTemporalZonedDateTime ( item [ , options ] )

The abstract operation ToTemporalZonedDateTime returns its argument item if it is already a Temporal.ZonedDateTime instance, converts item to a new Temporal.PlainDate instance if possible, and throws otherwise.

  1. If options is not present, set options to ! OrdinaryObjectCreate(null).
  2. Let offsetBehaviour be option.
  3. Let matchBehaviour be match exactly.
  4. If Type(item) is Object, then
    1. If item has an [[InitializedTemporalZonedDateTime]] internal slot, then
      1. Return item.
    2. Let calendar be ? GetTemporalCalendarWithISODefault(item).
    3. Let fieldNames be ? CalendarFields(calendar, « "day", "hour", "microsecond", "millisecond", "minute", "month", "monthCode", "nanosecond", "second", "year" »).
    4. Append "timeZone" to fieldNames.
    5. Append "offset" to fieldNames.
    6. Let fields be ? PrepareTemporalFields(item, fieldNames, « "timeZone" »).
    7. Let timeZone be ? Get(fields, "timeZone").
    8. Set timeZone to ? ToTemporalTimeZone(timeZone).
    9. Let offsetString be ? Get(fields, "offset").
    10. If offsetString is undefined, then
      1. Set offsetBehaviour to wall.
    11. Else,
      1. Set offsetString to ? ToString(offsetString).
    12. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
  5. Else,
    1. Perform ? ToTemporalOverflow(options).
    2. Let string be ? ToString(item).
    3. Let result be ? ParseTemporalZonedDateTimeString(string).
    4. Assert: result.[[TimeZoneName]] is not undefined.
    5. Let offsetString be result.[[TimeZoneOffsetString]].
    6. If result.[[TimeZoneZ]] is true, then
      1. Set offsetBehaviour to exact.
    7. Else if offsetString is undefined, then
      1. Set offsetBehaviour to wall.
    8. Let timeZone be ? CreateTemporalTimeZone(result.[[TimeZoneName]]).
    9. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
    10. Set matchBehaviour to match minutes.
  6. Let offsetNanoseconds be 0.
  7. If offsetBehaviour is option, then
    1. Set offsetNanoseconds to ? ParseTimeZoneOffsetString(offsetString).
  8. Let disambiguation be ? ToTemporalDisambiguation(options).
  9. Let offsetOption be ? ToTemporalOffset(options, "reject").
  10. Let epochNanoseconds be ? InterpretISODateTimeOffset(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], offsetBehaviour, offsetNanoseconds, timeZone, disambiguation, offsetOption, matchBehaviour).
  11. Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).

6.5.3 CreateTemporalZonedDateTime ( epochNanoseconds, timeZone, calendar [ , newTarget ] )

The abstract operation CreateTemporalZonedDateTime is used to specify the creation of a new Temporal.ZonedDateTime object.

  1. Assert: Type(epochNanoseconds) is BigInt.
  2. Assert: ! IsValidEpochNanoseconds(epochNanoseconds) is true.
  3. Assert: Type(timeZone) is Object.
  4. Assert: Type(calendar) is Object.
  5. If newTarget is not present, set it to %Temporal.ZonedDateTime%.
  6. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.ZonedDateTime.prototype%", « [[InitializedTemporalZonedDateTime]], [[Nanoseconds]], [[TimeZone]], [[Calendar]] »).
  7. Set object.[[Nanoseconds]] to epochNanoseconds.
  8. Set object.[[TimeZone]] to timeZone.
  9. Set object.[[Calendar]] to calendar.
  10. Return object.

6.5.4 TemporalZonedDateTimeToString ( zonedDateTime, precision, showCalendar, showTimeZone, showOffset [ , increment, unit, roundingMode ] )

The abstract operation TemporalZonedDateTimeToString returns an ISO 8601 string representation of its argument, including a time zone name annotation and calendar annotation, which are extensions to the ISO 8601 format.

  1. Assert: Type(zonedDateTime) is Object and zonedDateTime has an [[InitializedTemporalZonedDateTime]] internal slot.
  2. If increment is not present, set it to 1.
  3. If unit is not present, set it to "nanosecond".
  4. If roundingMode is not present, set it to "trunc".
  5. Let ns be ! RoundTemporalInstant(zonedDateTime.[[Nanoseconds]], increment, unit, roundingMode).
  6. Let timeZone be zonedDateTime.[[TimeZone]].
  7. Let instant be ! CreateTemporalInstant(ns).
  8. Let isoCalendar be ! GetISO8601Calendar().
  9. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, isoCalendar).
  10. Let dateTimeString be ? TemporalDateTimeToString(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], isoCalendar, precision, "never").
  11. If showOffset is "never", then
    1. Let offsetString be the empty String.
  12. Else,
    1. Let offsetNs be ? GetOffsetNanosecondsFor(timeZone, instant).
    2. Let offsetString be ! FormatISOTimeZoneOffsetString(offsetNs).
  13. If showTimeZone is "never", then
    1. Let timeZoneString be the empty String.
  14. Else,
    1. Let timeZoneID be ? ToString(timeZone).
    2. Let timeZoneString be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), timeZoneID, and the code unit 0x005D (RIGHT SQUARE BRACKET).
  15. Let calendarID be ? ToString(zonedDateTime.[[Calendar]]).
  16. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar).
  17. Return the string-concatenation of dateTimeString, offsetString, timeZoneString, and calendarString.

6.5.5 AddZonedDateTime ( epochNanoseconds, timeZone, calendar, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , options ] )

The abstract operation AddZonedDateTime adds a duration in various units to a number of nanoseconds epochNanoseconds since the Unix epoch, subject to the rules of timeZone and calendar. As specified in RFC 5545, the date portion of the duration is added in calendar days, and the time portion is added in exact time.

  1. If options is not present, set options to ! OrdinaryObjectCreate(null).
  2. If all of years, months, weeks, and days are 0, then
    1. Return ! AddInstant(epochNanoseconds, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
  3. Let instant be ! CreateTemporalInstant(epochNanoseconds).
  4. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
  5. Let datePart be ? CreateTemporalDate(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar).
  6. Let dateDuration be ? CreateTemporalDuration(years, months, weeks, days, 0, 0, 0, 0, 0, 0).
  7. Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
  8. Let intermediateDateTime be ? CreateTemporalDateTime(addedDate.[[ISOYear]], addedDate.[[ISOMonth]], addedDate.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], calendar).
  9. Let intermediateInstant be ? BuiltinTimeZoneGetInstantFor(timeZone, intermediateDateTime, "compatible").
  10. Return ! AddInstant(intermediateInstant.[[Nanoseconds]], hours, minutes, seconds, milliseconds, microseconds, nanoseconds).

6.5.6 DifferenceZonedDateTime ( ns1, ns2, timeZone, calendar, largestUnit [ , options ] )

The abstract operation DifferenceZonedDateTime computes the difference between two exact times expressed in nanoseconds since the Unix epoch, and balances the result so that there is no non-zero unit larger than largestUnit in the result, taking calendar reckoning and time zone offset changes into account.

  1. Assert: Type(ns1) is BigInt.
  2. Assert: Type(ns2) is BigInt.
  3. If ns1 is ns2, then
    1. Return the Record { [[Years]]: 0, [[Months]]: 0, [[Weeks]]: 0, [[Days]]: 0, [[Hours]]: 0, [[Minutes]]: 0, [[Seconds]]: 0, [[Milliseconds]]: 0, [[Microseconds]]: 0, [[Nanoseconds]]: 0 }.
  4. Let startInstant be ! CreateTemporalInstant(ns1).
  5. Let startDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, startInstant, calendar).
  6. Let endInstant be ! CreateTemporalInstant(ns2).
  7. Let endDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, endInstant, calendar).
  8. Let dateDifference be ? DifferenceISODateTime(startDateTime.[[ISOYear]], startDateTime.[[ISOMonth]], startDateTime.[[ISODay]], startDateTime.[[ISOHour]], startDateTime.[[ISOMinute]], startDateTime.[[ISOSecond]], startDateTime.[[ISOMillisecond]], startDateTime.[[ISOMicrosecond]], startDateTime.[[ISONanosecond]], endDateTime.[[ISOYear]], endDateTime.[[ISOMonth]], endDateTime.[[ISODay]], endDateTime.[[ISOHour]], endDateTime.[[ISOMinute]], endDateTime.[[ISOSecond]], endDateTime.[[ISOMillisecond]], endDateTime.[[ISOMicrosecond]], endDateTime.[[ISONanosecond]], calendar, largestUnit, options).
  9. Let intermediateNs be ? AddZonedDateTime(ns1, timeZone, calendar, dateDifference.[[Years]], dateDifference.[[Months]], dateDifference.[[Weeks]], 0, 0, 0, 0, 0, 0, 0).
  10. Let timeRemainderNs be ns2intermediateNs.
  11. Let intermediate be ! CreateTemporalZonedDateTime(intermediateNs, timeZone, calendar).
  12. Let result be ? NanosecondsToDays(timeRemainderNs, intermediate).
  13. Let timeDifference be ! BalanceDuration(0, 0, 0, 0, 0, 0, result.[[Nanoseconds]], "hour").
  14. Return the Record { [[Years]]: dateDifference.[[Years]], [[Months]]: dateDifference.[[Months]], [[Weeks]]: dateDifference.[[Weeks]], [[Days]]: result.[[Days]], [[Hours]]: timeDifference.[[Hours]], [[Minutes]]: timeDifference.[[Minutes]], [[Seconds]]: timeDifference.[[Seconds]], [[Milliseconds]]: timeDifference.[[Milliseconds]], [[Microseconds]]: timeDifference.[[Microseconds]], [[Nanoseconds]]: timeDifference.[[Nanoseconds]] }.

6.5.7 NanosecondsToDays ( nanoseconds, relativeTo )

The abstract operation NanosecondsToDays takes a number of nanoseconds relative to a Temporal.ZonedDateTime relativeTo, and converts it into a number of days and remainder of nanoseconds, taking into account any offset changes in the time zone of relativeTo. It also returns the length of the last day in nanoseconds, for rounding purposes.

  1. Assert: Type(nanoseconds) is BigInt.
  2. Set nanoseconds to (nanoseconds).
  3. Let sign be ! (Sign(𝔽(nanoseconds))).
  4. Let dayLengthNs be 8.64 × 1013.
  5. If sign is 0, then
    1. Return the Record { [[Days]]: 0, [[Nanoseconds]]: 0, [[DayLength]]: dayLengthNs }.
  6. If Type(relativeTo) is not Object or relativeTo does not have an [[InitializedTemporalZonedDateTime]] internal slot, then
    1. Return the Record { [[Days]]: the integral part of nanoseconds / dayLengthNs, [[Nanoseconds]]: (abs(nanoseconds) modulo dayLengthNs) × sign, [[DayLength]]: dayLengthNs }.
  7. Let startNs be (relativeTo.[[Nanoseconds]]).
  8. Let startInstant be ! CreateTemporalInstant(ℤ(startNs)).
  9. Let startDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(relativeTo.[[TimeZone]], startInstant, relativeTo.[[Calendar]]).
  10. Let endNs be startNs + nanoseconds.
  11. Let endInstant be ! CreateTemporalInstant(ℤ(endNs)).
  12. Let endDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(relativeTo.[[TimeZone]], endInstant, relativeTo.[[Calendar]]).
  13. Let dateDifference be ? DifferenceISODateTime(startDateTime.[[ISOYear]], startDateTime.[[ISOMonth]], startDateTime.[[ISODay]], startDateTime.[[ISOHour]], startDateTime.[[ISOMinute]], startDateTime.[[ISOSecond]], startDateTime.[[ISOMillisecond]], startDateTime.[[ISOMicrosecond]], startDateTime.[[ISONanosecond]], endDateTime.[[ISOYear]], endDateTime.[[ISOMonth]], endDateTime.[[ISODay]], endDateTime.[[ISOHour]], endDateTime.[[ISOMinute]], endDateTime.[[ISOSecond]], endDateTime.[[ISOMillisecond]], endDateTime.[[ISOMicrosecond]], endDateTime.[[ISONanosecond]], relativeTo.[[Calendar]], "day").
  14. Let days be dateDifference.[[Days]].
  15. Let intermediateNs be (? AddZonedDateTime(ℤ(startNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, days, 0, 0, 0, 0, 0, 0)).
  16. If sign is 1, then
    1. Repeat, while days > 0 and intermediateNs > endNs,
      1. Set days to days − 1.
      2. Set intermediateNs to (? AddZonedDateTime(ℤ(startNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, days, 0, 0, 0, 0, 0, 0)).
  17. Set nanoseconds to endNsintermediateNs.
  18. Let done be false.
  19. Repeat, while done is false,
    1. Let oneDayFartherNs be (? AddZonedDateTime(ℤ(intermediateNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, sign, 0, 0, 0, 0, 0, 0)).
    2. Set dayLengthNs to oneDayFartherNsintermediateNs.
    3. If (nanosecondsdayLengthNs) × sign ≥ 0, then
      1. Set nanoseconds to nanosecondsdayLengthNs.
      2. Set intermediateNs to oneDayFartherNs.
      3. Set days to days + sign.
    4. Else,
      1. Set done to true.
  20. Return the Record { [[Days]]: days, [[Nanoseconds]]: nanoseconds, [[DayLength]]: abs(dayLengthNs) }.

7 Temporal.Duration Objects

A Temporal.Duration object describes the difference in elapsed time between two other Temporal objects of the same type: Instant, PlainDate, PlainDateTime, PlainTime, PlainYearMonth, or ZonedDateTime. Objects of this type are only created via the .since() and .until() methods of these objects.

7.1 The Temporal.Duration Constructor

The Temporal.Duration constructor:

  • creates and initializes a new Temporal.Duration object when called as a constructor.
  • is not intended to be called as a function and will throw an exception when called in that manner.
  • may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Temporal.Duration behaviour must include a super call to the %Temporal.Duration% constructor to create and initialize subclass instances with the necessary internal slots.

7.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 ? ToIntegerOrInfinity(undefined) is 0.
  1. If NewTarget is undefined, then
    1. Throw a TypeError exception.
  2. Let y be ? ToIntegerWithoutRounding(years).
  3. Let mo be ? ToIntegerWithoutRounding(months).
  4. Let w be ? ToIntegerWithoutRounding(weeks).
  5. Let d be ? ToIntegerWithoutRounding(days).
  6. Let h be ? ToIntegerWithoutRounding(hours).
  7. Let m be ? ToIntegerWithoutRounding(minutes).
  8. Let s be ? ToIntegerWithoutRounding(seconds).
  9. Let ms be ? ToIntegerWithoutRounding(milliseconds).
  10. Let mis be ? ToIntegerWithoutRounding(microseconds).
  11. Let ns be ? ToIntegerWithoutRounding(nanoseconds).
  12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).

7.2 Properties of the Temporal.Duration Constructor

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

The Temporal.Duration constructor has the following properties:

7.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 }.

7.2.2 Temporal.Duration.from ( item )

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

  1. If Type(item) is Object and item has an [[InitializedTemporalDuration]] internal slot, then
    1. Return ? CreateTemporalDuration(item.[[Years]], item.[[Months]], item.[[Weeks]], item.[[Days]], item.[[Hours]], item.[[Minutes]], item.[[Seconds]], item.[[Milliseconds]], item.[[Microseconds]], item.[[Nanoseconds]]).
  2. Return ? ToTemporalDuration(item).

7.2.3 Temporal.Duration.compare ( one, two [ , options ] )

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

  1. Set one to ? ToTemporalDuration(one).
  2. Set two to ? ToTemporalDuration(two).
  3. Set options to ? GetOptionsObject(options).
  4. Let relativeTo be ? ToRelativeTemporalObject(options).
  5. Let shift1 be ? CalculateOffsetShift(relativeTo, one.[[Years]], one.[[Months]], one.[[Weeks]], one.[[Days]], one.[[Hours]], one.[[Minutes]], one.[[Seconds]], one.[[Milliseconds]], one.[[Microseconds]], one.[[Nanoseconds]]).
  6. Let shift2 be ? CalculateOffsetShift(relativeTo, two.[[Years]], two.[[Months]], two.[[Weeks]], two.[[Days]], two.[[Hours]], two.[[Minutes]], two.[[Seconds]], two.[[Milliseconds]], two.[[Microseconds]], two.[[Nanoseconds]]).
  7. If any of one.[[Years]], two.[[Years]], one.[[Months]], two.[[Months]], one.[[Weeks]], or two.[[Weeks]] are not 0, then
    1. Let unbalanceResult1 be ? UnbalanceDurationRelative(one.[[Years]], one.[[Months]], one.[[Weeks]], one.[[Days]], "day", relativeTo).
    2. Let unbalanceResult2 be ? UnbalanceDurationRelative(two.[[Years]], two.[[Months]], two.[[Weeks]], two.[[Days]], "day", relativeTo).
    3. Let days1 be unbalanceResult1.[[Days]].
    4. Let days2 be unbalanceResult2.[[Days]].
  8. Else,
    1. Let days1 be one.[[Days]].
    2. Let days2 be two.[[Days]].
  9. Let ns1 be ! TotalDurationNanoseconds(days1, one.[[Hours]], one.[[Minutes]], one.[[Seconds]], one.[[Milliseconds]], one.[[Microseconds]], one.[[Nanoseconds]], shift1).
  10. Let ns2 be ! TotalDurationNanoseconds(days2, two.[[Hours]], two.[[Minutes]], two.[[Seconds]], two.[[Milliseconds]], two.[[Microseconds]], two.[[Nanoseconds]], shift2).
  11. If ns1 > ns2, return 1.
  12. If ns1 < ns2, return −1.
  13. Return 0.

7.3 Properties of the Temporal.Duration Prototype Object

The Temporal.Duration prototype object

  • 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%.

7.3.1 Temporal.Duration.prototype.constructor

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

7.3.2 Temporal.Duration.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 }.

7.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]].

7.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]].

7.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]].

7.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]].

7.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]].

7.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]].

7.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]].

7.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]].

7.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]].

7.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]].

7.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]]).

7.3.14 get Temporal.Duration.prototype.blank

Temporal.Duration.prototype.blank 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. Let sign be ! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
  4. If sign = 0, return true.
  5. Return false.

7.3.15 Temporal.Duration.prototype.with ( temporalDurationLike )

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

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

7.3.16 Temporal.Duration.prototype.negated ( )

The following steps are taken:

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

7.3.17 Temporal.Duration.prototype.abs ( )

The following steps are taken:

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. Return ! CreateTemporalDuration(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]])).

7.3.18 Temporal.Duration.prototype.add ( other [ , options ] )

The add 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. Set options to ? GetOptionsObject(options).
  5. Let relativeTo be ? ToRelativeTemporalObject(options).
  6. Let result be ? AddDuration(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]], relativeTo).
  7. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

7.3.19 Temporal.Duration.prototype.subtract ( other [ , options ] )

The subtract 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. Set options to ? GetOptionsObject(options).
  5. Let relativeTo be ? ToRelativeTemporalObject(options).
  6. Let result be ? AddDuration(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]], relativeTo).
  7. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]).

7.3.20 Temporal.Duration.prototype.round ( roundTo )

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

  1. Let duration be the this value.
  2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
  3. If roundTo is undefined, then
    1. Throw a TypeError exception.
  4. If Type(roundTo) is String, then
    1. Let paramString be roundTo.
    2. Set roundTo to ! OrdinaryObjectCreate(null).
    3. Perform ! CreateDataPropertyOrThrow(roundTo, "_smallestUnit_", paramString).
  5. Else,
    1. Set roundTo to ? GetOptionsObject(roundTo).
  6. Let smallestUnitPresent be true.
  7. Let largestUnitPresent be true.
  8. Let smallestUnit be ? ToSmallestTemporalUnit(roundTo, « », undefined).
  9. If smallestUnit is undefined, then
    1. Set smallestUnitPr