Temporal.PlainYearMonth Objects

A Temporal.PlainYearMonth object is an Object that contains integers corresponding to a particular year and month in a particular calendar.

The Temporal.PlainYearMonth Constructor

The Temporal.PlainYearMonth constructor:

Temporal.PlainYearMonth ( _isoYear_, _isoMonth_ [ , _calendar_ [ , _referenceISODay_ ] ] )

This function performs the following steps when called:

1. If NewTarget is *undefined*, then 1. Throw a *TypeError* exception. 1. If _referenceISODay_ is *undefined*, then 1. Set _referenceISODay_ to *1*𝔽. 1. Let _y_ be ? ToIntegerWithTruncation(_isoYear_). 1. Let _m_ be ? ToIntegerWithTruncation(_isoMonth_). 1. If _calendar_ is *undefined*, set _calendar_ to *"iso8601"*. 1. If _calendar_ is not a String, throw a *TypeError* exception. 1. Set _calendar_ to ? CanonicalizeCalendar(_calendar_). 1. Let _ref_ be ? ToIntegerWithTruncation(_referenceISODay_). 1. If IsValidISODate(_y_, _m_, _ref_) is *false*, throw a *RangeError* exception. 1. Let _isoDate_ be CreateISODateRecord(_y_, _m_, _ref_). 1. Return ? CreateTemporalYearMonth(_isoDate_, _calendar_, NewTarget).

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

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

Properties of Temporal.PlainYearMonth Instances

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

Internal Slot Description
[[InitializedTemporalYearMonth]] The only specified use of this slot is for distinguishing Temporal.PlainYearMonth instances from other objects.
[[ISODate]] An ISO Date Record. The [[Day]] field is used by the calendar in the [[Calendar]] slot to disambiguate if the [[Year]] and [[Month]] fields are not sufficient to uniquely identify a year and month in that calendar.
[[Calendar]] A calendar type.

Abstract Operations

ISO Year-Month Records

An ISO Year-Month Record is a Record value used to represent a valid month in the ISO 8601 calendar, although the year may be outside of the allowed range for Temporal.

ISO Year-Month Records have the fields listed in .

Field Name Value Meaning
[[Year]] an integer The year in the ISO 8601 calendar.
[[Month]] an integer between 1 and 12, inclusive The number of the month in the ISO 8601 calendar.

ToTemporalYearMonth ( _item_: an ECMAScript language value, optional _options_: an ECMAScript language value, ): either a normal completion containing a Temporal.PlainYearMonth, or a throw completion

description
Converts _item_ to a new Temporal.PlainYearMonth instance if possible, and throws otherwise.
1. If _options_ is not present, set _options_ to *undefined*. 1. If _item_ is an Object, then 1. If _item_ has an [[InitializedTemporalYearMonth]] internal slot, then 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Perform ? GetTemporalOverflowOption(_resolvedOptions_). 1. Return ! CreateTemporalYearMonth(_item_.[[ISODate]], _item_.[[Calendar]]). 1. Let _calendar_ be ? GetTemporalCalendarIdentifierWithISODefault(_item_). 1. Let _fields_ be ? PrepareCalendarFields(_calendar_, _item_, « ~year~, ~month~, ~month-code~ », «», «»). 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_). 1. If _item_ is not a String, throw a *TypeError* exception. 1. Let _result_ be ? ParseISODateTime(_item_, « |TemporalYearMonthString| »). 1. Let _calendar_ be _result_.[[Calendar]]. 1. If _calendar_ is ~empty~, set _calendar_ to *"iso8601"*. 1. Set _calendar_ to ? CanonicalizeCalendar(_calendar_). 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Perform ? GetTemporalOverflowOption(_resolvedOptions_). 1. Let _isoDate_ be CreateISODateRecord(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]). 1. If ISOYearMonthWithinLimits(_isoDate_) is *false*, throw a *RangeError* exception. 1. Set _result_ to ISODateToFields(_calendar_, _isoDate_, ~year-month~). 1. NOTE: The following operation is called with ~constrain~ regardless of the value of _overflow_, in order for the calendar to store a canonical value in the [[Day]] field of the [[ISODate]] internal slot of the result. 1. Set _isoDate_ to ? CalendarYearMonthFromFields(_calendar_, _result_, ~constrain~). 1. Return ! CreateTemporalYearMonth(_isoDate_, _calendar_).

ISOYearMonthWithinLimits ( _isoDate_: an ISO Date Record, ): a Boolean

description
It returns *true* if its argument represents a month within the range that a Temporal.PlainYearMonth object can represent, and *false* otherwise.
1. If _isoDate_.[[Year]] < -271821 or _isoDate_.[[Year]] > 275760, then 1. Return *false*. 1. If _isoDate_.[[Year]] = -271821 and _isoDate_.[[Month]] < 4, then 1. Return *false*. 1. If _isoDate_.[[Year]] = 275760 and _isoDate_.[[Month]] > 9, then 1. Return *false*. 1. Return *true*.

Temporal.PlainYearMonth objects can represent any month that contains a day that a Temporal.PlainDate can represent. This ensures that a Temporal.PlainDate object can always be converted into a Temporal.PlainYearMonth object.

BalanceISOYearMonth ( _year_: an integer, _month_: an integer, ): an ISO Year-Month Record

description
1. Set _year_ to _year_ + floor((_month_ - 1) / 12). 1. Set _month_ to ((_month_ - 1) modulo 12) + 1. 1. Return ISO Year-Month Record { [[Year]]: _year_, [[Month]]: _month_ }.

CreateTemporalYearMonth ( _isoDate_: an ISO Date Record, _calendar_: a calendar type, optional _newTarget_: a constructor, ): either a normal completion containing a Temporal.PlainYearMonth or a throw completion

description
It creates a Temporal.PlainYearMonth instance and fills the internal slots with valid values.
1. If ISOYearMonthWithinLimits(_isoDate_) is *false*, throw a *RangeError* exception. 1. If _newTarget_ is not present, set _newTarget_ to %Temporal.PlainYearMonth%. 1. Let _object_ be ? OrdinaryCreateFromConstructor(_newTarget_, *"%Temporal.PlainYearMonth.prototype%"*, « [[InitializedTemporalYearMonth]], [[ISODate]], [[Calendar]] »). 1. Set _object_.[[ISODate]] to _isoDate_. 1. Set _object_.[[Calendar]] to _calendar_. 1. Return _object_.

TemporalYearMonthToString ( _yearMonth_: a Temporal.PlainYearMonth, _showCalendar_: ~auto~, ~always~, ~never~, or ~critical~, ): a String

description
It formats _yearMonth_ as an RFC 9557 string.
1. Let _year_ be PadISOYear(_yearMonth_.[[ISODate]].[[Year]]). 1. Let _month_ be ToZeroPaddedDecimalString(_yearMonth_.[[ISODate]].[[Month]], 2). 1. Let _result_ be the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), and _month_. 1. If _showCalendar_ is one of ~always~ or ~critical~, or if _yearMonth_.[[Calendar]] is not *"iso8601"*, then 1. Let _day_ be ToZeroPaddedDecimalString(_yearMonth_.[[ISODate]].[[Day]], 2). 1. Set _result_ to the string-concatenation of _result_, the code unit 0x002D (HYPHEN-MINUS), and _day_. 1. Let _calendarString_ be FormatCalendarAnnotation(_yearMonth_.[[Calendar]], _showCalendar_). 1. Set _result_ to the string-concatenation of _result_ and _calendarString_. 1. Return _result_.

DifferenceTemporalPlainYearMonth ( _operation_: ~since~ or ~until~, _yearMonth_: a Temporal.PlainYearMonth, _other_: an ECMAScript language value, _options_: an ECMAScript language value, ): either a normal completion containing a Temporal.Duration or a throw completion

description
It computes the difference between the two times represented by _yearMonth_ and _other_, optionally rounds it, and returns it as a Temporal.Duration object.
1. Set _other_ to ? ToTemporalYearMonth(_other_). 1. Let _calendar_ be _yearMonth_.[[Calendar]]. 1. If CalendarEquals(_calendar_, _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Let _settings_ be ? GetDifferenceSettings(_operation_, _resolvedOptions_, ~date~, « ~week~, ~day~ », ~month~, ~year~). 1. If CompareISODate(_yearMonth_.[[ISODate]], _other_.[[ISODate]]) = 0, then 1. Return ! CreateTemporalDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0). 1. Let _thisFields_ be ISODateToFields(_calendar_, _yearMonth_.[[ISODate]], ~year-month~). 1. Set _thisFields_.[[Day]] to 1. 1. Let _thisDate_ be ? CalendarDateFromFields(_calendar_, _thisFields_, ~constrain~). 1. Let _otherFields_ be ISODateToFields(_calendar_, _other_.[[ISODate]], ~year-month~). 1. Set _otherFields_.[[Day]] to 1. 1. Let _otherDate_ be ? CalendarDateFromFields(_calendar_, _otherFields_, ~constrain~). 1. Let _dateDifference_ be CalendarDateUntil(_calendar_, _thisDate_, _otherDate_, _settings_.[[LargestUnit]]). 1. Let _yearsMonthsDifference_ be ! AdjustDateDurationRecord(_dateDifference_, 0, 0). 1. Let _duration_ be CombineDateAndTimeDuration(_yearsMonthsDifference_, 0). 1. If _settings_.[[SmallestUnit]] is not ~month~ or _settings_.[[RoundingIncrement]] ≠ 1, then 1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_thisDate_, MidnightTimeRecord()). 1. Let _isoDateTimeOther_ be CombineISODateAndTimeRecord(_otherDate_, MidnightTimeRecord()). 1. Let _destEpochNs_ be GetUTCEpochNanoseconds(_isoDateTimeOther_). 1. Set _duration_ to ? RoundRelativeDuration(_duration_, _destEpochNs_, _isoDateTime_, ~unset~, _calendar_, _settings_.[[LargestUnit]], _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]). 1. Let _result_ be ! TemporalDurationFromInternal(_duration_, ~day~). 1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_). 1. Return _result_.

AddDurationToYearMonth ( _operation_: ~add~ or ~subtract~, _yearMonth_: a Temporal.PlainYearMonth, _temporalDurationLike_: an ECMAScript language value, _options_: an ECMAScript language value, ): either a normal completion containing a Temporal.PlainYearMonth or a throw completion

description
It adds/subtracts _temporalDurationLike_ to/from _yearMonth_, returning a point in time that is in the future/past relative to _yearMonth_.
1. Let _duration_ be ? ToTemporalDuration(_temporalDurationLike_). 1. If _operation_ is ~subtract~, set _duration_ to CreateNegatedTemporalDuration(_duration_). 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_). 1. Let _sign_ be DurationSign(_duration_). 1. Let _calendar_ be _yearMonth_.[[Calendar]]. 1. Let _fields_ be ISODateToFields(_calendar_, _yearMonth_.[[ISODate]], ~year-month~). 1. Set _fields_.[[Day]] to 1. 1. Let _intermediateDate_ be ? CalendarDateFromFields(_calendar_, _fields_, ~constrain~). 1. If _sign_ < 0, then 1. Let _oneMonthDuration_ be ! CreateDateDurationRecord(0, 1, 0, 0). 1. Let _nextMonth_ be ? CalendarDateAdd(_calendar_, _intermediateDate_, _oneMonthDuration_, ~constrain~). 1. Let _date_ be BalanceISODate(_nextMonth_.[[Year]], _nextMonth_.[[Month]], _nextMonth_.[[Day]] - 1). 1. Assert: ISODateWithinLimits(_date_) is *true*. 1. Else, 1. Let _date_ be _intermediateDate_. 1. Let _durationToAdd_ be ToDateDurationRecordWithoutTime(_duration_). 1. Let _addedDate_ be ? CalendarDateAdd(_calendar_, _date_, _durationToAdd_, _overflow_). 1. Let _addedDateFields_ be ISODateToFields(_calendar_, _addedDate_, ~year-month~). 1. Let _isoDate_ be ? CalendarYearMonthFromFields(_calendar_, _addedDateFields_, _overflow_). 1. Return ! CreateTemporalYearMonth(_isoDate_, _calendar_).