A Temporal.PlainDateTime object is an Object that contains integers corresponding to a particular year, month, day, hour, minute, second, millisecond, microsecond, and nanosecond.
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%.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
Temporal.PlainDateTime.prototype.constructor
The initial value of `Temporal.PlainDateTime.prototype.constructor` is %Temporal.PlainDateTime%.
Temporal.PlainDateTime.prototype[ %Symbol.toStringTag% ]
The initial value of the %Symbol.toStringTag% property is the String value *"Temporal.PlainDateTime"*.
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
get Temporal.PlainDateTime.prototype.calendarId
`Temporal.PlainDateTime.prototype.calendarId` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return _dateTime_.[[Calendar]].
get Temporal.PlainDateTime.prototype.era
`Temporal.PlainDate.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _plainDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDateTime_, [[InitializedTemporalDateTime]]).
1. Return CalendarISOToDate(_plainDateTime_.[[Calendar]], _plainDateTime_.[[ISODateTime]].[[ISODate]]).[[Era]].
get Temporal.PlainDateTime.prototype.eraYear
`Temporal.PlainDateTime.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _plainDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDateTime_, [[InitializedTemporalDateTime]]).
1. Let _result_ be CalendarISOToDate(_plainDateTime_.[[Calendar]], _plainDateTime_.[[ISODateTime]].[[ISODate]]).[[EraYear]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[Year]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[Month]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[MonthCode]].
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[Day]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(_dateTime_.[[ISODateTime]].[[Time]].[[Hour]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(_dateTime_.[[ISODateTime]].[[Time]].[[Minute]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(_dateTime_.[[ISODateTime]].[[Time]].[[Second]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(_dateTime_.[[ISODateTime]].[[Time]].[[Millisecond]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(_dateTime_.[[ISODateTime]].[[Time]].[[Microsecond]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(_dateTime_.[[ISODateTime]].[[Time]].[[Nanosecond]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[DayOfWeek]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[DayOfYear]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Let _result_ be CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[WeekOfYear]].[[Week]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
get Temporal.PlainDateTime.prototype.yearOfWeek
`Temporal.PlainDateTime.prototype.yearOfWeek` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Let _result_ be CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[WeekOfYear]].[[Year]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[DaysInWeek]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[DaysInMonth]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[DaysInYear]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return 𝔽(CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[MonthsInYear]]).
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.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return CalendarISOToDate(_dateTime_.[[Calendar]], _dateTime_.[[ISODateTime]].[[ISODate]]).[[InLeapYear]].
Temporal.PlainDateTime.prototype.with ( _temporalDateTimeLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. If ? IsPartialTemporalObject(_temporalDateTimeLike_) is *false*, throw a *TypeError* exception.
1. Let _calendar_ be _dateTime_.[[Calendar]].
1. Let _fields_ be ISODateToFields(_calendar_, _dateTime_.[[ISODateTime]].[[ISODate]], ~date~).
1. Set _fields_.[[Hour]] to _dateTime_.[[ISODateTime]].[[Time]].[[Hour]].
1. Set _fields_.[[Minute]] to _dateTime_.[[ISODateTime]].[[Time]].[[Minute]].
1. Set _fields_.[[Second]] to _dateTime_.[[ISODateTime]].[[Time]].[[Second]].
1. Set _fields_.[[Millisecond]] to _dateTime_.[[ISODateTime]].[[Time]].[[Millisecond]].
1. Set _fields_.[[Microsecond]] to _dateTime_.[[ISODateTime]].[[Time]].[[Microsecond]].
1. Set _fields_.[[Nanosecond]] to _dateTime_.[[ISODateTime]].[[Time]].[[Nanosecond]].
1. Let _partialDateTime_ be ? PrepareCalendarFields(_calendar_, _temporalDateTimeLike_, « ~year~, ~month~, ~month-code~, ~day~ », « ~hour~, ~minute~, ~second~, ~millisecond~, ~microsecond~, ~nanosecond~ », ~partial~).
1. Set _fields_ to CalendarMergeFields(_calendar_, _fields_, _partialDateTime_).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_).
1. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _overflow_).
1. Return ? CreateTemporalDateTime(_result_, _calendar_).
Temporal.PlainDateTime.prototype.withPlainTime ( [ _plainTimeLike_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Let _time_ be ? ToTimeRecordOrMidnight(_plainTimeLike_).
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_dateTime_.[[ISODateTime]].[[ISODate]], _time_).
1. Return ? CreateTemporalDateTime(_isoDateTime_, _dateTime_.[[Calendar]]).
Temporal.PlainDateTime.prototype.withCalendar ( _calendarLike_ )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Let _calendar_ be ? ToTemporalCalendarIdentifier(_calendarLike_).
1. Return ! CreateTemporalDateTime(_dateTime_.[[ISODateTime]], _calendar_).
Temporal.PlainDateTime.prototype.add ( _temporalDurationLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ? AddDurationToDateTime(~add~, _dateTime_, _temporalDurationLike_, _options_).
Temporal.PlainDateTime.prototype.subtract ( _temporalDurationLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ? AddDurationToDateTime(~subtract~, _dateTime_, _temporalDurationLike_, _options_).
Temporal.PlainDateTime.prototype.until ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ? DifferenceTemporalPlainDateTime(~until~, _dateTime_, _other_, _options_).
Temporal.PlainDateTime.prototype.since ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ? DifferenceTemporalPlainDateTime(~since~, _dateTime_, _other_, _options_).
Temporal.PlainDateTime.prototype.round ( _roundTo_ )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. If _roundTo_ is *undefined*, then
1. Throw a *TypeError* exception.
1. If _roundTo_ is a String, then
1. Let _paramString_ be _roundTo_.
1. Set _roundTo_ to OrdinaryObjectCreate(*null*).
1. Perform ! CreateDataPropertyOrThrow(_roundTo_, *"smallestUnit"*, _paramString_).
1. Else,
1. Set _roundTo_ to ? GetOptionsObject(_roundTo_).
1. NOTE: The following steps read options and perform independent validation in alphabetical order (GetRoundingIncrementOption reads *"roundingIncrement"* and GetRoundingModeOption reads *"roundingMode"*).
1. Let _roundingIncrement_ be ? GetRoundingIncrementOption(_roundTo_).
1. Let _roundingMode_ be ? GetRoundingModeOption(_roundTo_, ~half-expand~).
1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_roundTo_, *"smallestUnit"*, ~time~, ~required~, « ~day~ »).
1. If _smallestUnit_ is ~day~, then
1. Let _maximum_ be 1.
1. Let _inclusive_ be *true*.
1. Else,
1. Let _maximum_ be MaximumTemporalDurationRoundingIncrement(_smallestUnit_).
1. Assert: _maximum_ is not ~unset~.
1. Let _inclusive_ be *false*.
1. Perform ? ValidateTemporalRoundingIncrement(_roundingIncrement_, _maximum_, _inclusive_).
1. If _smallestUnit_ is ~nanosecond~ and _roundingIncrement_ = 1, then
1. Return ! CreateTemporalDateTime(_dateTime_.[[ISODateTime]], _dateTime_.[[Calendar]]).
1. Let _result_ be RoundISODateTime(_dateTime_.[[ISODateTime]], _roundingIncrement_, _smallestUnit_, _roundingMode_).
1. Return ? CreateTemporalDateTime(_result_, _dateTime_.[[Calendar]]).
Temporal.PlainDateTime.prototype.equals ( _other_ )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Set _other_ to ? ToTemporalDateTime(_other_).
1. If CompareISODateTime(_dateTime_.[[ISODateTime]], _other_.[[ISODateTime]]) ≠ 0, return *false*.
1. Return CalendarEquals(_dateTime_.[[Calendar]], _other_.[[Calendar]]).
Temporal.PlainDateTime.prototype.toString ( [ _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. NOTE: The following steps read options and perform independent validation in alphabetical order (GetTemporalShowCalendarNameOption reads *"calendarName"*, GetTemporalFractionalSecondDigitsOption reads *"fractionalSecondDigits"*, and GetRoundingModeOption reads *"roundingMode"*).
1. Let _showCalendar_ be ? GetTemporalShowCalendarNameOption(_resolvedOptions_).
1. Let _digits_ be ? GetTemporalFractionalSecondDigitsOption(_resolvedOptions_).
1. Let _roundingMode_ be ? GetRoundingModeOption(_resolvedOptions_, ~trunc~).
1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_resolvedOptions_, *"smallestUnit"*, ~time~, ~unset~).
1. If _smallestUnit_ is ~hour~, throw a *RangeError* exception.
1. Let _precision_ be ToSecondsStringPrecisionRecord(_smallestUnit_, _digits_).
1. Let _result_ be RoundISODateTime(_dateTime_.[[ISODateTime]], _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_).
1. If ISODateTimeWithinLimits(_result_) is *false*, throw a *RangeError* exception.
1. Return ISODateTimeToString(_result_, _dateTime_.[[Calendar]], _precision_.[[Precision]], _showCalendar_).
Temporal.PlainDateTime.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:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ISODateTimeToString(_dateTime_.[[ISODateTime]], _dateTime_.[[Calendar]], ~auto~, ~auto~).
Temporal.PlainDateTime.prototype.toJSON ( )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ISODateTimeToString(_dateTime_.[[ISODateTime]], _dateTime_.[[Calendar]], ~auto~, ~auto~).
Temporal.PlainDateTime.prototype.valueOf ( )
This method performs the following steps when called:
1. Throw a *TypeError* exception.
This method always throws, because in the absence of `valueOf()`, expressions with arithmetic operators such as `plainDateTime1 > plainDateTime2` would fall back to being equivalent to `plainDateTime1.toString() > plainDateTime2.toString()`.
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to `Temporal.PlainDateTime.compare()`, `Temporal.PlainDateTime.prototype.equals()`, and/or `Temporal.PlainDateTime.prototype.toString()`.
Temporal.PlainDateTime.prototype.toZonedDateTime ( _temporalTimeZoneLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Let _timeZone_ be ? ToTemporalTimeZoneIdentifier(_temporalTimeZoneLike_).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _disambiguation_ be ? GetTemporalDisambiguationOption(_resolvedOptions_).
1. Let _epochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _dateTime_.[[ISODateTime]], _disambiguation_).
1. Return ! CreateTemporalZonedDateTime(_epochNs_, _timeZone_, _dateTime_.[[Calendar]]).
Temporal.PlainDateTime.prototype.toPlainDate ( )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ! CreateTemporalDate(_dateTime_.[[ISODateTime]].[[ISODate]], _dateTime_.[[Calendar]]).
Temporal.PlainDateTime.prototype.toPlainTime ( )
This method performs the following steps when called:
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ! CreateTemporalTime(_dateTime_.[[ISODateTime]].[[Time]]).