A Temporal.PlainYearMonth object is an Object that contains integers corresponding to a particular year and month in a particular calendar.
Properties of the Temporal.PlainYearMonth Constructor
The value of the [[Prototype]] internal slot of the Temporal.PlainYearMonth constructor is the intrinsic object %Function.prototype%.
The Temporal.PlainYearMonth constructor has the following properties:
Temporal.PlainYearMonth.prototype
The initial value of `Temporal.PlainYearMonth.prototype` is %Temporal.PlainYearMonth.prototype%.
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
Temporal.PlainYearMonth.from ( _item_ [ , _options_ ] )
This function performs the following steps when called:
1. Return ? ToTemporalYearMonth(_item_, _options_).
Temporal.PlainYearMonth.compare ( _one_, _two_ )
This function performs the following steps when called:
1. Set _one_ to ? ToTemporalYearMonth(_one_).
1. Set _two_ to ? ToTemporalYearMonth(_two_).
1. Return 𝔽(CompareISODate(_one_.[[ISODate]], _two_.[[ISODate]])).
Properties of the Temporal.PlainYearMonth Prototype Object
The Temporal.PlainYearMonth prototype object
- is itself an ordinary object.
- is not a Temporal.PlainYearMonth instance and does not have a [[InitializedTemporalYearMonth]] 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.PlainYearMonth.prototype.constructor
The initial value of `Temporal.PlainYearMonth.prototype.constructor` is %Temporal.PlainYearMonth%.
Temporal.PlainYearMonth.prototype[ %Symbol.toStringTag% ]
The initial value of the %Symbol.toStringTag% property is the String value *"Temporal.PlainYearMonth"*.
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
get Temporal.PlainYearMonth.prototype.calendarId
`Temporal.PlainYearMonth.prototype.calendarId` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return _yearMonth_.[[Calendar]].
get Temporal.PlainYearMonth.prototype.era
`Temporal.PlainYearMonth.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _plainYearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainYearMonth_, [[InitializedTemporalYearMonth]]).
1. Return CalendarISOToDate(_plainYearMonth_.[[Calendar]], _plainYearMonth_.[[ISODate]]).[[Era]].
get Temporal.PlainYearMonth.prototype.eraYear
`Temporal.PlainYearMonth.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _plainYearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainYearMonth_, [[InitializedTemporalYearMonth]]).
1. Let _result_ be CalendarISOToDate(_plainYearMonth_.[[Calendar]], _plainYearMonth_.[[ISODate]]).[[EraYear]].
1. If _result_ is *undefined*, return *undefined*.
1. Return 𝔽(_result_).
get Temporal.PlainYearMonth.prototype.year
`Temporal.PlainYearMonth.prototype.year` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return 𝔽(CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[Year]]).
get Temporal.PlainYearMonth.prototype.month
`Temporal.PlainYearMonth.prototype.month` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return 𝔽(CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[Month]]).
get Temporal.PlainYearMonth.prototype.monthCode
`Temporal.PlainYearMonth.prototype.monthCode` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[MonthCode]].
get Temporal.PlainYearMonth.prototype.daysInYear
`Temporal.PlainYearMonth.prototype.daysInYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return 𝔽(CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[Day]]).
get Temporal.PlainYearMonth.prototype.daysInMonth
`Temporal.PlainYearMonth.prototype.daysInMonth` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return 𝔽(CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[DaysInMonth]]).
get Temporal.PlainYearMonth.prototype.monthsInYear
`Temporal.PlainYearMonth.prototype.monthsInYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return 𝔽(CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[MonthsInYear]]).
get Temporal.PlainYearMonth.prototype.inLeapYear
`Temporal.PlainYearMonth.prototype.inLeapYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return CalendarISOToDate(_yearMonth_.[[Calendar]], _yearMonth_.[[ISODate]]).[[InLeapYear]].
Temporal.PlainYearMonth.prototype.with ( _temporalYearMonthLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. If ? IsPartialTemporalObject(_temporalYearMonthLike_) is *false*, throw a *TypeError* exception.
1. Let _calendar_ be _yearMonth_.[[Calendar]].
1. Let _fields_ be ISODateToFields(_calendar_, _yearMonth_.[[ISODate]], ~year-month~).
1. Let _partialYearMonth_ be ? PrepareCalendarFields(_calendar_, _temporalYearMonthLike_, « ~year~, ~month~, ~month-code~ », « », ~partial~).
1. Set _fields_ to CalendarMergeFields(_calendar_, _fields_, _partialYearMonth_).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_).
1. Let _isoDate_ be ? CalendarYearMonthFromFields(_calendar_, _fields_, _overflow_).
1. Return ! CreateTemporalYearMonth(_isoDate_, _calendar_).
Temporal.PlainYearMonth.prototype.add ( _temporalDurationLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return ? AddDurationToYearMonth(~add~, _yearMonth_, _temporalDurationLike_, _options_).
Temporal.PlainYearMonth.prototype.subtract ( _temporalDurationLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return ? AddDurationToYearMonth(~subtract~, _yearMonth_, _temporalDurationLike_, _options_).
Temporal.PlainYearMonth.prototype.until ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return ? DifferenceTemporalPlainYearMonth(~until~, _yearMonth_, _other_, _options_).
Temporal.PlainYearMonth.prototype.since ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return ? DifferenceTemporalPlainYearMonth(~since~, _yearMonth_, _other_, _options_).
Temporal.PlainYearMonth.prototype.equals ( _other_ )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Set _other_ to ? ToTemporalYearMonth(_other_).
1. If CompareISODate(_yearMonth_.[[ISODate]], _other_.[[ISODate]]) ≠ 0, return *false*.
1. Return CalendarEquals(_yearMonth_.[[Calendar]], _other_.[[Calendar]]).
Temporal.PlainYearMonth.prototype.toString ( [ _options_ ] )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _showCalendar_ be ? GetTemporalShowCalendarNameOption(_resolvedOptions_).
1. Return TemporalYearMonthToString(_yearMonth_, _showCalendar_).
Temporal.PlainYearMonth.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 _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return TemporalYearMonthToString(_yearMonth_, ~auto~).
Temporal.PlainYearMonth.prototype.toJSON ( )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return TemporalYearMonthToString(_yearMonth_, ~auto~).
Temporal.PlainYearMonth.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 `plainYearMonth1 > plainYearMonth2` would fall back to being equivalent to `plainYearMonth1.toString() > plainYearMonth2.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.PlainYearMonth.compare()`, `Temporal.PlainYearMonth.prototype.equals()`, and/or `Temporal.PlainYearMonth.prototype.toString()`.
Temporal.PlainYearMonth.prototype.toPlainDate ( _item_ )
This method performs the following steps when called:
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. If _item_ is not an Object, then
1. Throw a *TypeError* exception.
1. Let _calendar_ be _yearMonth_.[[Calendar]].
1. Let _fields_ be ISODateToFields(_calendar_, _yearMonth_.[[ISODate]], ~year-month~).
1. Let _inputFields_ be ? PrepareCalendarFields(_calendar_, _item_, « ~day~ », « », « »).
1. Let _mergedFields_ be CalendarMergeFields(_calendar_, _fields_, _inputFields_).
1. Let _isoDate_ be ? CalendarDateFromFields(_calendar_, _mergedFields_, ~constrain~).
1. Return ! CreateTemporalDate(_isoDate_, _calendar_).