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%.
Note
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
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.calendarId
Temporal.ZonedDateTime.prototype.calendarId
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? ToTemporalCalendarIdentifier(zonedDateTime.[[Calendar]]).
6.3.4 get Temporal.ZonedDateTime.prototype.timeZoneId
Temporal.ZonedDateTime.prototype.timeZoneId
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? ToTemporalTimeZoneIdentifier(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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let ns be zonedDateTime.[[Nanoseconds]].
- Let s be floor(ℝ(ns) / 109).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let ns be zonedDateTime.[[Nanoseconds]].
- Let ms be floor(ℝ(ns) / 106).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let ns be zonedDateTime.[[Nanoseconds]].
- Let µs be floor(ℝ(ns) / 103).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- 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:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return 𝔽(? CalendarWeekOfYear(calendar, temporalDateTime)).
6.3.22 get Temporal.ZonedDateTime.prototype.yearOfWeek
Temporal.ZonedDateTime.prototype.yearOfWeek
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return 𝔽(? CalendarYearOfWeek(calendar, temporalDateTime)).
6.3.23 get Temporal.ZonedDateTime.prototype.hoursInDay
Temporal.ZonedDateTime.prototype.hoursInDay
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, "iso8601").
- Let year be temporalDateTime.[[ISOYear]].
- Let month be temporalDateTime.[[ISOMonth]].
- Let day be temporalDateTime.[[ISODay]].
- Let today be ? CreateTemporalDateTime(year, month, day, 0, 0, 0, 0, 0, 0, "iso8601").
- Let tomorrowFields be BalanceISODate(year, month, day + 1).
- Let tomorrow be ? CreateTemporalDateTime(tomorrowFields.[[Year]], tomorrowFields.[[Month]], tomorrowFields.[[Day]], 0, 0, 0, 0, 0, 0, "iso8601").
- Let todayInstant be ? GetInstantFor(timeZone, today, "compatible").
- Let tomorrowInstant be ? GetInstantFor(timeZone, tomorrow, "compatible").
- Let diffNs be tomorrowInstant.[[Nanoseconds]] - todayInstant.[[Nanoseconds]].
- Return 𝔽(diffNs / (3.6 × 1012)).
6.3.24 get Temporal.ZonedDateTime.prototype.daysInWeek
Temporal.ZonedDateTime.prototype.daysInWeek
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return 𝔽(? CalendarDaysInWeek(calendar, temporalDateTime)).
6.3.25 get Temporal.ZonedDateTime.prototype.daysInMonth
Temporal.ZonedDateTime.prototype.daysInMonth
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return 𝔽(? CalendarDaysInMonth(calendar, temporalDateTime)).
6.3.26 get Temporal.ZonedDateTime.prototype.daysInYear
Temporal.ZonedDateTime.prototype.daysInYear
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return 𝔽(? CalendarDaysInYear(calendar, temporalDateTime)).
6.3.27 get Temporal.ZonedDateTime.prototype.monthsInYear
Temporal.ZonedDateTime.prototype.monthsInYear
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return 𝔽(? CalendarMonthsInYear(calendar, temporalDateTime)).
6.3.28 get Temporal.ZonedDateTime.prototype.inLeapYear
Temporal.ZonedDateTime.prototype.inLeapYear
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return ? CalendarInLeapYear(calendar, temporalDateTime).
6.3.29 get Temporal.ZonedDateTime.prototype.offsetNanoseconds
Temporal.ZonedDateTime.prototype.offsetNanoseconds
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Return 𝔽(? GetOffsetNanosecondsFor(timeZone, instant)).
6.3.30 get Temporal.ZonedDateTime.prototype.offset
Temporal.ZonedDateTime.prototype.offset
is an accessor property whose set accessor function is undefined.
Its get accessor function performs the following steps:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Return ? GetOffsetStringFor(zonedDateTime.[[TimeZone]], instant).
6.3.31 Temporal.ZonedDateTime.prototype.with ( temporalZonedDateTimeLike [ , options ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- If Type(temporalZonedDateTimeLike) is not Object, then
- Throw a TypeError exception.
- Perform ? RejectTemporalLikeObject(temporalZonedDateTimeLike).
- Set options to ? GetOptionsObject(options).
- Let calendar be zonedDateTime.[[Calendar]].
- Let fieldNames be ? CalendarFields(calendar, « "day", "hour", "microsecond", "millisecond", "minute", "month", "monthCode", "nanosecond", "second", "year" »).
- Append "offset" to fieldNames.
- Let fields be ? PrepareTemporalFields(zonedDateTime, fieldNames, « "offset" »).
- Let partialZonedDateTime be ? PrepareTemporalFields(temporalZonedDateTimeLike, fieldNames, partial).
- Set fields to ? CalendarMergeFields(calendar, fields, partialZonedDateTime).
- Set fields to ? PrepareTemporalFields(fields, fieldNames, « "offset" »).
- NOTE: The following steps read options and perform independent validation in alphabetical order (ToTemporalDisambiguation reads "disambiguation", ToTemporalOffset reads "offset", and InterpretTemporalDateTimeFields reads "overflow").
- Let disambiguation be ? ToTemporalDisambiguation(options).
- Let offset be ? ToTemporalOffset(options, "prefer").
- Let dateTimeResult be ? InterpretTemporalDateTimeFields(calendar, fields, options).
- Let offsetString be ! Get(fields, "offset").
- Assert: Type(offsetString) is String.
- If IsTimeZoneOffsetString(offsetString) is false, throw a RangeError exception.
- Let offsetNanoseconds be ParseTimeZoneOffsetString(offsetString).
- Let timeZone be zonedDateTime.[[TimeZone]].
- 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).
- Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).
6.3.32 Temporal.ZonedDateTime.prototype.withPlainTime ( [ plainTimeLike ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- If plainTimeLike is undefined, then
- Let plainTime be ! CreateTemporalTime(0, 0, 0, 0, 0, 0).
- Else,
- Let plainTime be ? ToTemporalTime(plainTimeLike).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let plainDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let resultPlainDateTime be ? CreateTemporalDateTime(plainDateTime.[[ISOYear]], plainDateTime.[[ISOMonth]], plainDateTime.[[ISODay]], plainTime.[[ISOHour]], plainTime.[[ISOMinute]], plainTime.[[ISOSecond]], plainTime.[[ISOMillisecond]], plainTime.[[ISOMicrosecond]], plainTime.[[ISONanosecond]], calendar).
- Set instant to ? GetInstantFor(timeZone, resultPlainDateTime, "compatible").
- Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar).
6.3.33 Temporal.ZonedDateTime.prototype.withPlainDate ( plainDateLike )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let plainDate be ? ToTemporalDate(plainDateLike).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let plainDateTime be ? GetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).
- Let calendar be ? ConsolidateCalendars(zonedDateTime.[[Calendar]], plainDate.[[Calendar]]).
- Let resultPlainDateTime be ? CreateTemporalDateTime(plainDate.[[ISOYear]], plainDate.[[ISOMonth]], plainDate.[[ISODay]], plainDateTime.[[ISOHour]], plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]], plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]], plainDateTime.[[ISONanosecond]], calendar).
- Set instant to ? GetInstantFor(timeZone, resultPlainDateTime, "compatible").
- Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar).
6.3.34 Temporal.ZonedDateTime.prototype.withTimeZone ( timeZoneLike )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be ? ToTemporalTimeZoneSlotValue(timeZoneLike).
- Return ! CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]], timeZone, zonedDateTime.[[Calendar]]).
6.3.35 Temporal.ZonedDateTime.prototype.withCalendar ( calendarLike )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let calendar be ? ToTemporalCalendarSlotValue(calendarLike).
- Return ! CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]], zonedDateTime.[[TimeZone]], calendar).
6.3.36 Temporal.ZonedDateTime.prototype.add ( temporalDurationLike [ , options ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? AddDurationToOrSubtractDurationFromZonedDateTime(add, zonedDateTime, temporalDurationLike, options).
6.3.37 Temporal.ZonedDateTime.prototype.subtract ( temporalDurationLike [ , options ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? AddDurationToOrSubtractDurationFromZonedDateTime(subtract, zonedDateTime, temporalDurationLike, options).
6.3.38 Temporal.ZonedDateTime.prototype.until ( other [ , options ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? DifferenceTemporalZonedDateTime(until, zonedDateTime, other, options).
6.3.39 Temporal.ZonedDateTime.prototype.since ( other [ , options ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? DifferenceTemporalZonedDateTime(since, zonedDateTime, other, options).
6.3.40 Temporal.ZonedDateTime.prototype.round ( roundTo )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- If roundTo is undefined, then
- Throw a TypeError exception.
- If Type(roundTo) is String, then
- Let paramString be roundTo.
- Set roundTo to OrdinaryObjectCreate(null).
- Perform ! CreateDataPropertyOrThrow(roundTo, "smallestUnit", paramString).
- Else,
- Set roundTo to ? GetOptionsObject(roundTo).
- NOTE: The following steps read options and perform independent validation in alphabetical order (ToTemporalRoundingIncrement reads "roundingIncrement" and ToTemporalRoundingMode reads "roundingMode").
- Let roundingIncrement be ? ToTemporalRoundingIncrement(roundTo).
- Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand").
- Let smallestUnit be ? GetTemporalUnit(roundTo, "smallestUnit", time, required, « "day" »).
- If smallestUnit is "day", then
- Let maximum be 1.
- Let inclusive be true.
- Else,
- Let maximum be ! MaximumTemporalDurationRoundingIncrement(smallestUnit).
- Assert: maximum is not undefined.
- Let inclusive be false.
- Perform ? ValidateTemporalRoundingIncrement(roundingIncrement, maximum, inclusive).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let dtStart be ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], 0, 0, 0, 0, 0, 0, "iso8601").
- Let instantStart be ? GetInstantFor(timeZone, dtStart, "compatible").
- Let startNs be instantStart.[[Nanoseconds]].
- Let endNs be ? AddZonedDateTime(startNs, timeZone, calendar, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0).
- Let dayLengthNs be ℝ(endNs - startNs).
- If dayLengthNs ≤ 0, then
- Throw a RangeError exception.
- 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).
- Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
- 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).
- Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).
6.3.41 Temporal.ZonedDateTime.prototype.equals ( other )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Set other to ? ToTemporalZonedDateTime(other).
- If zonedDateTime.[[Nanoseconds]] ≠ other.[[Nanoseconds]], return false.
- If ? TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, return false.
- Return ? CalendarEquals(zonedDateTime.[[Calendar]], other.[[Calendar]]).
6.3.42 Temporal.ZonedDateTime.prototype.toString ( [ options ] )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Set options to ? GetOptionsObject(options).
- NOTE: The following steps read options and perform independent validation in alphabetical order (ToCalendarNameOption reads "calendarName", ToFractionalSecondDigits reads "fractionalSecondDigits", ToShowOffsetOption reads "offset", and ToTemporalRoundingMode reads "roundingMode").
- Let showCalendar be ? ToCalendarNameOption(options).
- Let digits be ? ToFractionalSecondDigits(options).
- Let showOffset be ? ToShowOffsetOption(options).
- Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
- Let smallestUnit be ? GetTemporalUnit(options, "smallestUnit", time, undefined).
- If smallestUnit is "hour", throw a RangeError exception.
- Let showTimeZone be ? ToTimeZoneNameOption(options).
- Let precision be ToSecondsStringPrecisionRecord(smallestUnit, digits).
- Return ? TemporalZonedDateTimeToString(zonedDateTime, precision.[[Precision]], showCalendar, showTimeZone, showOffset, precision.[[Increment]], precision.[[Unit]], roundingMode).
6.3.43 Temporal.ZonedDateTime.prototype.toLocaleString ( [ locales [ , options ] ] )
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification.
If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used.
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").
6.3.44 Temporal.ZonedDateTime.prototype.toJSON ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").
6.3.45 Temporal.ZonedDateTime.prototype.valueOf ( )
This method performs the following steps when called:
- Throw a TypeError exception.
6.3.46 Temporal.ZonedDateTime.prototype.startOfDay ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let calendar be zonedDateTime.[[Calendar]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let startDateTime be ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], 0, 0, 0, 0, 0, 0, calendar).
- Let startInstant be ? GetInstantFor(timeZone, startDateTime, "compatible").
- Return ! CreateTemporalZonedDateTime(startInstant.[[Nanoseconds]], timeZone, calendar).
6.3.47 Temporal.ZonedDateTime.prototype.toInstant ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
6.3.48 Temporal.ZonedDateTime.prototype.toPlainDate ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return ! CreateTemporalDate(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar).
6.3.49 Temporal.ZonedDateTime.prototype.toPlainTime ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Return ! CreateTemporalTime(temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]]).
6.3.50 Temporal.ZonedDateTime.prototype.toPlainDateTime ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Return ? GetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).
6.3.51 Temporal.ZonedDateTime.prototype.toPlainYearMonth ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let fieldNames be ? CalendarFields(calendar, « "monthCode", "year" »).
- Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
- Return ? CalendarYearMonthFromFields(calendar, fields).
- NOTE: The call to CalendarYearMonthFromFields is necessary in order to create a PlainYearMonth object with the [[ISOYear]], [[ISOMonth]], and [[ISODay]] internal slots set correctly.
6.3.52 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »).
- Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
- Return ? CalendarMonthDayFromFields(calendar, fields).
- NOTE: The call to CalendarMonthDayFromFields is necessary in order to create a PlainMonthDay object with the [[ISOYear]], [[ISOMonth]], and [[ISODay]] internal slots set correctly.
6.3.53 Temporal.ZonedDateTime.prototype.getISOFields ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Let fields be OrdinaryObjectCreate(%Object.prototype%).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
- Let calendar be zonedDateTime.[[Calendar]].
- Let dateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let offset be ? GetOffsetStringFor(timeZone, instant).
- Perform ! CreateDataPropertyOrThrow(fields, "calendar", calendar).
- Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(dateTime.[[ISODay]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(dateTime.[[ISOHour]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(dateTime.[[ISOMicrosecond]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(dateTime.[[ISOMillisecond]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(dateTime.[[ISOMinute]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(dateTime.[[ISOMonth]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(dateTime.[[ISONanosecond]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(dateTime.[[ISOSecond]])).
- Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(dateTime.[[ISOYear]])).
- Perform ! CreateDataPropertyOrThrow(fields, "offset", offset).
- Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone).
- Return fields.
6.3.54 Temporal.ZonedDateTime.prototype.getCalendar ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ToTemporalCalendarObject(zonedDateTime.[[Calendar]]).
6.3.55 Temporal.ZonedDateTime.prototype.getTimeZone ( )
This method performs the following steps when called:
- Let zonedDateTime be the this value.
- Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
- Return ToTemporalTimeZoneObject(zonedDateTime.[[TimeZone]]).
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 takes arguments year (an integer), month (an integer), day (an integer), hour (an integer), minute (an integer), second (an integer), millisecond (an integer), microsecond (an integer), nanosecond (an integer), offsetBehaviour (one of option, exact, or wall), offsetNanoseconds (an integer), timeZone (an Object), disambiguation (one of "earlier", "later", "compatible", or "reject"), offsetOption (one of "ignore", "use", "prefer", or "reject"), and matchBehaviour (one of match exactly or match minutes) and returns either a normal completion containing a BigInt or an abrupt completion.
It 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, disambiguation and offsetOption.
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.
It performs the following steps when called:
- Assert: IsValidISODate(year, month, day) is true.
- Let dateTime be ? CreateTemporalDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, "iso8601").
- If offsetBehaviour is wall or offsetOption is "ignore", then
- Let instant be ? GetInstantFor(timeZone, dateTime, disambiguation).
- Return instant.[[Nanoseconds]].
- If offsetBehaviour is exact or offsetOption is "use", then
- Let epochNanoseconds be GetUTCEpochNanoseconds(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond).
- Set epochNanoseconds to epochNanoseconds - ℤ(offsetNanoseconds).
- If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception.
- Return epochNanoseconds.
- Assert: offsetBehaviour is option.
- Assert: offsetOption is "prefer" or "reject".
- Let possibleInstants be ? GetPossibleInstantsFor(timeZone, dateTime).
- For each element candidate of possibleInstants, do
- Let candidateNanoseconds be ? GetOffsetNanosecondsFor(timeZone, candidate).
- If candidateNanoseconds = offsetNanoseconds, then
- Return candidate.[[Nanoseconds]].
- If matchBehaviour is match minutes, then
- Let roundedCandidateNanoseconds be RoundNumberToIncrement(candidateNanoseconds, 60 × 109, "halfExpand").
- If roundedCandidateNanoseconds = offsetNanoseconds, then
- Return candidate.[[Nanoseconds]].
- If offsetOption is "reject", throw a RangeError exception.
- Let instant be ? DisambiguatePossibleInstants(possibleInstants, timeZone, dateTime, disambiguation).
- Return instant.[[Nanoseconds]].
6.5.2 ToTemporalZonedDateTime ( item [ , options ] )
The abstract operation ToTemporalZonedDateTime takes argument item (an ECMAScript language value) and optional argument options (an Object) and returns either a normal completion containing a Temporal.ZonedDateTime
or an abrupt completion.
It returns its argument item if it is already a Temporal.ZonedDateTime instance, converts item to a new Temporal.ZonedDateTime instance if possible, and throws otherwise.
It performs the following steps when called:
- If options is not present, set options to undefined.
- Assert: Type(options) is Object or Undefined.
- Let offsetBehaviour be option.
- Let matchBehaviour be match exactly.
- If Type(item) is Object, then
- If item has an [[InitializedTemporalZonedDateTime]] internal slot, then
- Return item.
- Let calendar be ? GetTemporalCalendarSlotValueWithISODefault(item).
- Let fieldNames be ? CalendarFields(calendar, « "day", "hour", "microsecond", "millisecond", "minute", "month", "monthCode", "nanosecond", "second", "year" »).
- Append "timeZone" to fieldNames.
- Append "offset" to fieldNames.
- Let fields be ? PrepareTemporalFields(item, fieldNames, « "timeZone" »).
- Let timeZone be ! Get(fields, "timeZone").
- Set timeZone to ? ToTemporalTimeZoneSlotValue(timeZone).
- Let offsetString be ! Get(fields, "offset").
- Assert: offsetString is a String or undefined.
- If offsetString is undefined, then
- Set offsetBehaviour to wall.
- NOTE: The following steps read options and perform independent validation in alphabetical order (ToTemporalDisambiguation reads "disambiguation", ToTemporalOffset reads "offset", and InterpretTemporalDateTimeFields reads "overflow").
- Let disambiguation be ? ToTemporalDisambiguation(options).
- Let offsetOption be ? ToTemporalOffset(options, "reject").
- Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
- Else,
- Let string be ? ToString(item).
- Let result be ? ParseTemporalZonedDateTimeString(string).
- Let timeZoneName be result.[[TimeZone]].[[Name]].
- Assert: timeZoneName is not undefined.
- Let timeZone be ? ToTemporalTimeZoneSlotValue(timeZoneName).
- Let offsetString be result.[[TimeZone]].[[OffsetString]].
- If result.[[TimeZone]].[[Z]] is true, then
- Set offsetBehaviour to exact.
- Else if offsetString is undefined, then
- Set offsetBehaviour to wall.
- Let calendar be result.[[Calendar]].
- If calendar is undefined, set calendar to "iso8601".
- If IsBuiltinCalendar(calendar) is false, throw a RangeError exception.
- Set calendar to the ASCII-lowercase of calendar.
- Set matchBehaviour to match minutes.
- Let disambiguation be ? ToTemporalDisambiguation(options).
- Let offsetOption be ? ToTemporalOffset(options, "reject").
- Perform ? ToTemporalOverflow(options).
- Let offsetNanoseconds be 0.
- If offsetBehaviour is option, then
- If IsTimeZoneOffsetString(offsetString) is false, throw a RangeError exception.
- Set offsetNanoseconds to ParseTimeZoneOffsetString(offsetString).
- 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).
- Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).
6.5.3 CreateTemporalZonedDateTime ( epochNanoseconds, timeZone, calendar [ , newTarget ] )
The abstract operation CreateTemporalZonedDateTime takes arguments epochNanoseconds (a BigInt), timeZone (a String or Object), and calendar (a String or Object) and optional argument newTarget (a constructor) and returns either a normal completion containing a Temporal.ZonedDateTime, or an abrupt completion. It creates a Temporal.ZonedDateTime instance and fills the internal slots with valid values. It performs the following steps when called:
- Assert: ! IsValidEpochNanoseconds(epochNanoseconds) is true.
- If newTarget is not present, set newTarget to %Temporal.ZonedDateTime%.
- Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.ZonedDateTime.prototype%", « [[InitializedTemporalZonedDateTime]], [[Nanoseconds]], [[TimeZone]], [[Calendar]] »).
- Set object.[[Nanoseconds]] to epochNanoseconds.
- Set object.[[TimeZone]] to timeZone.
- Set object.[[Calendar]] to calendar.
- Return object.
6.5.4 TemporalZonedDateTimeToString ( zonedDateTime, precision, showCalendar, showTimeZone, showOffset [ , increment [ , unit [ , roundingMode ] ] ] )
The abstract operation TemporalZonedDateTimeToString takes arguments zonedDateTime (a Temporal.ZonedDateTime), precision (one of "auto", "minute", or an integer between 0 and 9 inclusive), showCalendar (one of "auto", "always", "never", or "critical"), showTimeZone (one of "auto", "never", or "critical"), and showOffset (one of "auto" or "never") and optional arguments increment (an integer), unit (one of "minute", "second", "millisecond", "microsecond", or "nanosecond"), and roundingMode (one of "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", or "halfEven") and returns either a normal completion containing a String or an abrupt completion.
It 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.
It performs the following steps when called:
- If increment is not present, set increment to 1.
- If unit is not present, set unit to "nanosecond".
- If roundingMode is not present, set roundingMode to "trunc".
- Let ns be RoundTemporalInstant(zonedDateTime.[[Nanoseconds]], increment, unit, roundingMode).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let instant be ! CreateTemporalInstant(ns).
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, "iso8601").
- Let dateTimeString be ! TemporalDateTimeToString(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], "iso8601", precision, "never").
- If showOffset is "never", then
- Let offsetString be the empty String.
- Else,
- Let offsetNs be ? GetOffsetNanosecondsFor(timeZone, instant).
- Let offsetString be ! FormatISOTimeZoneOffsetString(offsetNs).
- If showTimeZone is "never", then
- Let timeZoneString be the empty String.
- Else,
- Let timeZoneIdentifier be ? ToTemporalTimeZoneIdentifier(timeZone).
- If showTimeZone is "critical", let flag be "!"; else let flag be the empty String.
- Let timeZoneString be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), flag, timeZoneIdentifier, and the code unit 0x005D (RIGHT SQUARE BRACKET).
- Let calendarString be ? MaybeFormatCalendarAnnotation(zonedDateTime.[[Calendar]], showCalendar).
- 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 takes arguments epochNanoseconds (a BigInt), timeZone (an Object), calendar (an Object), years (an integer), months (an integer), weeks (an integer), days (an integer), hours (an integer), minutes (an integer), seconds (an integer), milliseconds (an integer), microseconds (an integer), and nanoseconds (an integer) and optional argument options (an Object) and returns either a normal completion containing a BigInt or an abrupt completion.
It adds a duration in various units to a number of nanoseconds epochNanoseconds since the Unix epoch, subject to the rules of timeZone and calendar, and returns the result as a BigInt value.
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.
It performs the following steps when called:
- If options is not present, set options to undefined.
- Assert: Type(options) is Object or Undefined.
- If years = 0, months = 0, weeks = 0, and days = 0, then
- Return ? AddInstant(epochNanoseconds, hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
- Let instant be ! CreateTemporalInstant(epochNanoseconds).
- Let temporalDateTime be ? GetPlainDateTimeFor(timeZone, instant, calendar).
- Let datePart be ! CreateTemporalDate(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar).
- Let dateDuration be ! CreateTemporalDuration(years, months, weeks, days, 0, 0, 0, 0, 0, 0).
- Let addedDate be ? CalendarDateAdd(calendar, datePart, dateDuration, options).
- Let intermediateDateTime be ? CreateTemporalDateTime(addedDate.[[ISOYear]], addedDate.[[ISOMonth]], addedDate.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], calendar).
- Let intermediateInstant be ? GetInstantFor(timeZone, intermediateDateTime, "compatible").
- Return ? AddInstant(intermediateInstant.[[Nanoseconds]], hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
6.5.6 DifferenceZonedDateTime ( ns1, ns2, timeZone, calendar, largestUnit, options )
The abstract operation DifferenceZonedDateTime takes arguments ns1 (a BigInt), ns2 (a BigInt), timeZone (an Object), calendar (an Object), largestUnit (a String), and options (an Object) and returns either a normal completion containing a Duration Record or an abrupt completion.
It 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.
It performs the following steps when called:
- If ns1 is ns2, then
- Return ! CreateDurationRecord(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
- Let startInstant be ! CreateTemporalInstant(ns1).
- Let startDateTime be ? GetPlainDateTimeFor(timeZone, startInstant, calendar).
- Let endInstant be ! CreateTemporalInstant(ns2).
- Let endDateTime be ? GetPlainDateTimeFor(timeZone, endInstant, calendar).
- 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).
- Let intermediateNs be ? AddZonedDateTime(ns1, timeZone, calendar, dateDifference.[[Years]], dateDifference.[[Months]], dateDifference.[[Weeks]], 0, 0, 0, 0, 0, 0, 0).
- Let timeRemainderNs be ns2 - intermediateNs.
- Let intermediate be ! CreateTemporalZonedDateTime(intermediateNs, timeZone, calendar).
- Let result be ? NanosecondsToDays(ℝ(timeRemainderNs), intermediate).
- Let timeDifference be ! BalanceDuration(0, 0, 0, 0, 0, 0, result.[[Nanoseconds]], "hour").
- Return ! CreateDurationRecord(dateDifference.[[Years]], dateDifference.[[Months]], dateDifference.[[Weeks]], result.[[Days]], timeDifference.[[Hours]], timeDifference.[[Minutes]], timeDifference.[[Seconds]], timeDifference.[[Milliseconds]], timeDifference.[[Microseconds]], timeDifference.[[Nanoseconds]]).
6.5.7 NanosecondsToDays ( nanoseconds, relativeTo )
The abstract operation NanosecondsToDays takes arguments nanoseconds (an integer) and relativeTo (undefined, a Temporal.PlainDate, or a Temporal.ZonedDateTime) and returns either a normal completion containing a Record with fields [[Days]] (an integer), [[Nanoseconds]] (an integer), and [[DayLength]] (an integer), or an abrupt completion.
It converts 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.
It performs the following steps when called:
- Let dayLengthNs be nsPerDay.
- If nanoseconds = 0, then
- Return the Record { [[Days]]: 0, [[Nanoseconds]]: 0, [[DayLength]]: dayLengthNs }.
- If nanoseconds < 0, let sign be -1; else, let sign be 1.
- If Type(relativeTo) is not Object or relativeTo does not have an [[InitializedTemporalZonedDateTime]] internal slot, then
- Return the Record {
[[Days]]: truncate(nanoseconds / dayLengthNs),
[[Nanoseconds]]: (abs(nanoseconds) modulo dayLengthNs) × sign,
[[DayLength]]: dayLengthNs
}.
- Let startNs be ℝ(relativeTo.[[Nanoseconds]]).
- Let startInstant be ! CreateTemporalInstant(ℤ(startNs)).
- Let startDateTime be ? GetPlainDateTimeFor(relativeTo.[[TimeZone]], startInstant, relativeTo.[[Calendar]]).
- Let endNs be startNs + nanoseconds.
- If ! IsValidEpochNanoseconds(ℤ(endNs)) is false, throw a RangeError exception.
- Let endInstant be ! CreateTemporalInstant(ℤ(endNs)).
- Let endDateTime be ? GetPlainDateTimeFor(relativeTo.[[TimeZone]], endInstant, relativeTo.[[Calendar]]).
- 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", OrdinaryObjectCreate(null)).
- Let days be dateDifference.[[Days]].
- Let intermediateNs be ℝ(? AddZonedDateTime(ℤ(startNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, days, 0, 0, 0, 0, 0, 0)).
- If sign is 1, then
- Repeat, while days > 0 and intermediateNs > endNs,
- Set days to days - 1.
- Set intermediateNs to ℝ(? AddZonedDateTime(ℤ(startNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, days, 0, 0, 0, 0, 0, 0)).
- Set nanoseconds to endNs - intermediateNs.
- Let done be false.
- Repeat, while done is false,
- Let oneDayFartherNs be ℝ(? AddZonedDateTime(ℤ(intermediateNs), relativeTo.[[TimeZone]], relativeTo.[[Calendar]], 0, 0, 0, sign, 0, 0, 0, 0, 0, 0)).
- Set dayLengthNs to oneDayFartherNs - intermediateNs.
- If (nanoseconds - dayLengthNs) × sign ≥ 0, then
- Set nanoseconds to nanoseconds - dayLengthNs.
- Set intermediateNs to oneDayFartherNs.
- Set days to days + sign.
- Else,
- Set done to true.
- If days < 0 and sign = 1, throw a RangeError exception.
- If days > 0 and sign = -1, throw a RangeError exception.
- If nanoseconds < 0, then
- Assert: sign is -1.
- If nanoseconds > 0 and sign = -1, throw a RangeError exception.
- Assert: The inequality abs(nanoseconds) < abs(dayLengthNs) holds.
- Return the Record {
[[Days]]: days,
[[Nanoseconds]]: nanoseconds,
[[DayLength]]: abs(dayLengthNs)
}.
6.5.8 DifferenceTemporalZonedDateTime ( operation, zonedDateTime, other, options )
The abstract operation DifferenceTemporalZonedDateTime takes arguments operation (until or since), zonedDateTime (a Temporal.ZonedDateTime), other (an ECMAScript language value), and options (an ECMAScript language value) and returns either a normal completion containing a Temporal.Duration or an abrupt completion. It computes the difference between the two times represented by zonedDateTime and other, optionally rounds it, and returns it as a Temporal.Duration object. It performs the following steps when called:
- If operation is since, let sign be -1. Otherwise, let sign be 1.
- Set other to ? ToTemporalZonedDateTime(other).
- If ? CalendarEquals(zonedDateTime.[[Calendar]], other.[[Calendar]]) is false, then
- Throw a RangeError exception.
- Let resolvedOptions be ? SnapshotOwnProperties(? GetOptionsObject(options), null).
- Let settings be ? GetDifferenceSettings(operation, resolvedOptions, datetime, « », "nanosecond", "hour").
- Perform ! CreateDataPropertyOrThrow(resolvedOptions, "largestUnit", settings.[[LargestUnit]]).
- If settings.[[LargestUnit]] is not one of "year", "month", "week", or "day", then
- Let result be DifferenceInstant(zonedDateTime.[[Nanoseconds]], other.[[Nanoseconds]], settings.[[RoundingIncrement]], settings.[[SmallestUnit]], settings.[[LargestUnit]], settings.[[RoundingMode]]).
- Return ! CreateTemporalDuration(0, 0, 0, 0, sign × result.[[Hours]], sign × result.[[Minutes]], sign × result.[[Seconds]], sign × result.[[Milliseconds]], sign × result.[[Microseconds]], sign × result.[[Nanoseconds]]).
- If ? TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, then
- Throw a RangeError exception.
- Let difference be ? DifferenceZonedDateTime(zonedDateTime.[[Nanoseconds]], other.[[Nanoseconds]], zonedDateTime.[[TimeZone]], zonedDateTime.[[Calendar]], settings.[[LargestUnit]], resolvedOptions).
- Let roundResult be (? RoundDuration(difference.[[Years]], difference.[[Months]], difference.[[Weeks]], difference.[[Days]], difference.[[Hours]], difference.[[Minutes]], difference.[[Seconds]], difference.[[Milliseconds]], difference.[[Microseconds]], difference.[[Nanoseconds]], settings.[[RoundingIncrement]], settings.[[SmallestUnit]], settings.[[RoundingMode]], zonedDateTime)).[[DurationRecord]].
- Let result be ? AdjustRoundedDurationDays(roundResult.[[Years]], roundResult.[[Months]], roundResult.[[Weeks]], roundResult.[[Days]], roundResult.[[Hours]], roundResult.[[Minutes]], roundResult.[[Seconds]], roundResult.[[Milliseconds]], roundResult.[[Microseconds]], roundResult.[[Nanoseconds]], settings.[[RoundingIncrement]], settings.[[SmallestUnit]], settings.[[RoundingMode]], zonedDateTime).
- Return ! CreateTemporalDuration(sign × result.[[Years]], sign × result.[[Months]], sign × result.[[Weeks]], sign × result.[[Days]], sign × result.[[Hours]], sign × result.[[Minutes]], sign × result.[[Seconds]], sign × result.[[Milliseconds]], sign × result.[[Microseconds]], sign × result.[[Nanoseconds]]).
6.5.9 AddDurationToOrSubtractDurationFromZonedDateTime ( operation, zonedDateTime, temporalDurationLike, options )
The abstract operation AddDurationToOrSubtractDurationFromZonedDateTime takes arguments operation (add or subtract), zonedDateTime (a Temporal.ZonedDateTime), temporalDurationLike (an ECMAScript language value), and options (an ECMAScript language value) and returns either a normal completion containing a Temporal.ZonedDateTime or an abrupt completion. It adds/subtracts temporalDurationLike to/from zonedDateTime. It performs the following steps when called:
- If operation is subtract, let sign be -1. Otherwise, let sign be 1.
- Let duration be ? ToTemporalDurationRecord(temporalDurationLike).
- Set options to ? GetOptionsObject(options).
- Let timeZone be zonedDateTime.[[TimeZone]].
- Let calendar be zonedDateTime.[[Calendar]].
- Let epochNanoseconds be ? AddZonedDateTime(zonedDateTime.[[Nanoseconds]], timeZone, calendar, sign × duration.[[Years]], sign × duration.[[Months]], sign × duration.[[Weeks]], sign × duration.[[Days]], sign × duration.[[Hours]], sign × duration.[[Minutes]], sign × duration.[[Seconds]], sign × duration.[[Milliseconds]], sign × duration.[[Microseconds]], sign × duration.[[Nanoseconds]], options).
- Return ! CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar).