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.
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%.
An ECMAScript implementation that includes the ECMA-402 Internationalization API extends this prototype with additional properties in order to represent calendar data.
Temporal.PlainDate.prototype.constructor
The initial value of `Temporal.PlainDate.prototype.constructor` is %Temporal.PlainDate%.
Temporal.PlainDate.prototype[ %Symbol.toStringTag% ]
The initial value of the %Symbol.toStringTag% property is the String value *"Temporal.PlainDate"*.
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
get Temporal.PlainDate.prototype.calendarId
`Temporal.PlainDate.prototype.calendarId` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return _temporalDate_.[[Calendar]].
get Temporal.PlainDate.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 _plainDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDate_, [[InitializedTemporalDate]]).
1. Return CalendarISOToDate(_plainDate_.[[Calendar]], _plainDate_.[[ISODate]]).[[Era]].
get Temporal.PlainDate.prototype.eraYear
`Temporal.PlainDate.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _plainDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDate_, [[InitializedTemporalDate]]).
1. Let _result_ be CalendarISOToDate(_plainDate_.[[Calendar]], _plainDate_.[[ISODate]]).[[EraYear]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[Year]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[Month]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[MonthCode]].
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[Day]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[DayOfWeek]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[DayOfYear]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _result_ be CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[WeekOfYear]].[[Week]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
get Temporal.PlainDate.prototype.yearOfWeek
`Temporal.PlainDate.prototype.yearOfWeek` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _result_ be CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[WeekOfYear]].[[Year]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[DaysInWeek]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[DaysInMonth]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[DaysInYear]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return 𝔽(CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[MonthsInYear]]).
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.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return CalendarISOToDate(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]]).[[InLeapYear]].
Temporal.PlainDate.prototype.toPlainYearMonth ( )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be _temporalDate_.[[Calendar]].
1. Let _fields_ be ISODateToFields(_calendar_, _temporalDate_.[[ISODate]], ~date~).
1. Let _isoDate_ be ? CalendarYearMonthFromFields(_calendar_, _fields_, ~constrain~).
1. Return ! CreateTemporalYearMonth(_isoDate_, _calendar_).
1. NOTE: The call to CalendarYearMonthFromFields is necessary in order to create a PlainYearMonth object with the [[Day]] field of the [[ISODate]] internal slot set correctly.
Temporal.PlainDate.prototype.toPlainMonthDay ( )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be _temporalDate_.[[Calendar]].
1. Let _fields_ be ISODateToFields(_calendar_, _temporalDate_.[[ISODate]], ~date~).
1. Let _isoDate_ be ? CalendarMonthDayFromFields(_calendar_, _fields_, ~constrain~).
1. Return ! CreateTemporalMonthDay(_isoDate_, _calendar_).
1. NOTE: The call to CalendarMonthDayFromFields is necessary in order to create a PlainMonthDay object with the [[Year]] field of the [[ISODate]] internal slot set correctly.
Temporal.PlainDate.prototype.add ( _temporalDurationLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return ? AddDurationToDate(~add~, _temporalDate_, _temporalDurationLike_, _options_).
Temporal.PlainDate.prototype.subtract ( _temporalDurationLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return ? AddDurationToDate(~subtract~, _temporalDate_, _temporalDurationLike_, _options_).
Temporal.PlainDate.prototype.with ( _temporalDateLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. If ? IsPartialTemporalObject(_temporalDateLike_) is *false*, throw a *TypeError* exception.
1. Let _calendar_ be _temporalDate_.[[Calendar]].
1. Let _fields_ be ISODateToFields(_calendar_, _temporalDate_.[[ISODate]], ~date~).
1. Let _partialDate_ be ? PrepareCalendarFields(_calendar_, _temporalDateLike_, « ~year~, ~month~, ~month-code~, ~day~ », « », ~partial~).
1. Set _fields_ to CalendarMergeFields(_calendar_, _fields_, _partialDate_).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_).
1. Let _isoDate_ be ? CalendarDateFromFields(_calendar_, _fields_, _overflow_).
1. Return ! CreateTemporalDate(_isoDate_, _calendar_).
Temporal.PlainDate.prototype.withCalendar ( _calendarLike_ )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be ? ToTemporalCalendarIdentifier(_calendarLike_).
1. Return ! CreateTemporalDate(_temporalDate_.[[ISODate]], _calendar_).
Temporal.PlainDate.prototype.until ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return ? DifferenceTemporalPlainDate(~until~, _temporalDate_, _other_, _options_).
Temporal.PlainDate.prototype.since ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return ? DifferenceTemporalPlainDate(~since~, _temporalDate_, _other_, _options_).
Temporal.PlainDate.prototype.equals ( _other_ )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Set _other_ to ? ToTemporalDate(_other_).
1. If CompareISODate(_temporalDate_.[[ISODate]], _other_.[[ISODate]]) ≠ 0, return *false*.
1. Return CalendarEquals(_temporalDate_.[[Calendar]], _other_.[[Calendar]]).
Temporal.PlainDate.prototype.toPlainDateTime ( [ _temporalTime_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _time_ be ? ToTimeRecordOrMidnight(_temporalTime_).
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_temporalDate_.[[ISODate]], _time_).
1. Return ? CreateTemporalDateTime(_isoDateTime_, _temporalDate_.[[Calendar]]).
Temporal.PlainDate.prototype.toZonedDateTime ( _item_ )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. If _item_ is an Object, then
1. Let _timeZoneLike_ be ? Get(_item_, *"timeZone"*).
1. If _timeZoneLike_ is *undefined*, then
1. Let _timeZone_ be ? ToTemporalTimeZoneIdentifier(_item_).
1. Let _temporalTime_ be *undefined*.
1. Else,
1. Let _timeZone_ be ? ToTemporalTimeZoneIdentifier(_timeZoneLike_).
1. Let _temporalTime_ be ? Get(_item_, *"plainTime"*).
1. Else,
1. Let _timeZone_ be ? ToTemporalTimeZoneIdentifier(_item_).
1. Let _temporalTime_ be *undefined*.
1. If _temporalTime_ is *undefined*, then
1. Let _epochNs_ be ? GetStartOfDay(_timeZone_, _temporalDate_.[[ISODate]]).
1. Else,
1. Set _temporalTime_ to ? ToTemporalTime(_temporalTime_).
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_temporalDate_.[[ISODate]], _temporalTime_.[[Time]]).
1. If ISODateTimeWithinLimits(_isoDateTime_) is *false*, throw a *RangeError* exception.
1. Let _epochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _isoDateTime_, ~compatible~).
1. Return ! CreateTemporalZonedDateTime(_epochNs_, _timeZone_, _temporalDate_.[[Calendar]]).
Temporal.PlainDate.prototype.toString ( [ _options_ ] )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _showCalendar_ be ? GetTemporalShowCalendarNameOption(_resolvedOptions_).
1. Return TemporalDateToString(_temporalDate_, _showCalendar_).
Temporal.PlainDate.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 _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return TemporalDateToString(_temporalDate_, ~auto~).
Temporal.PlainDate.prototype.toJSON ( )
This method performs the following steps when called:
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return TemporalDateToString(_temporalDate_, ~auto~).
Temporal.PlainDate.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 `plainDate1 > plainDate2` would fall back to being equivalent to `plainDate1.toString() > plainDate2.toString()`.
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to `Temporal.PlainDate.compare()`, `Temporal.PlainDate.prototype.equals()`, and/or `Temporal.PlainDate.prototype.toString()`.