Temporal.PlainMonthDay Objects

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

The Temporal.PlainMonthDay Constructor

The Temporal.PlainMonthDay constructor:

Temporal.PlainMonthDay ( _isoMonth_, _isoDay_ [ , _calendar_ [ , _referenceISOYear_ ] ] )

This function performs the following steps when called:

1. If NewTarget is *undefined*, then 1. Throw a *TypeError* exception. 1. If _referenceISOYear_ is *undefined*, then 1. Set _referenceISOYear_ to *1972*𝔽 (the first ISO 8601 leap year after the epoch). 1. Let _m_ be ? ToIntegerWithTruncation(_isoMonth_). 1. Let _d_ be ? ToIntegerWithTruncation(_isoDay_). 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 _y_ be ? ToIntegerWithTruncation(_referenceISOYear_). 1. If IsValidISODate(_y_, _m_, _d_) is *false*, throw a *RangeError* exception. 1. Let _isoDate_ be CreateISODateRecord(_y_, _m_, _d_). 1. Return ? CreateTemporalMonthDay(_isoDate_, _calendar_, NewTarget).

Properties of the Temporal.PlainMonthDay Constructor

The value of the [[Prototype]] internal slot of the Temporal.PlainMonthDay constructor is the intrinsic object %Function.prototype%.

The Temporal.PlainMonthDay constructor has the following properties:

Temporal.PlainMonthDay.prototype

The initial value of `Temporal.PlainMonthDay.prototype` is %Temporal.PlainMonthDay.prototype%.

This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.

Temporal.PlainMonthDay.from ( _item_ [ , _options_ ] )

This function performs the following steps when called:

1. Return ? ToTemporalMonthDay(_item_, _options_).

Properties of the Temporal.PlainMonthDay Prototype Object

The Temporal.PlainMonthDay 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.PlainMonthDay.prototype.constructor

The initial value of `Temporal.PlainMonthDay.prototype.constructor` is %Temporal.PlainMonthDay%.

Temporal.PlainMonthDay.prototype[ %Symbol.toStringTag% ]

The initial value of the %Symbol.toStringTag% property is the String value *"Temporal.PlainMonthDay"*.

This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

get Temporal.PlainMonthDay.prototype.calendarId

`Temporal.PlainMonthDay.prototype.calendarId` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Return _monthDay_.[[Calendar]].

get Temporal.PlainMonthDay.prototype.monthCode

`Temporal.PlainMonthDay.prototype.monthCode` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Return CalendarISOToDate(_monthDay_.[[Calendar]], _monthDay_.[[ISODate]]).[[MonthCode]].

get Temporal.PlainMonthDay.prototype.day

`Temporal.PlainMonthDay.prototype.day` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Return 𝔽(CalendarISOToDate(_monthDay_.[[Calendar]], _monthDay_.[[ISODate]]).[[Day]]).

Temporal.PlainMonthDay.prototype.with ( _temporalMonthDayLike_ [ , _options_ ] )

This method performs the following steps when called:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. If ? IsPartialTemporalObject(_temporalMonthDayLike_) is *false*, throw a *TypeError* exception. 1. Let _calendar_ be _monthDay_.[[Calendar]]. 1. Let _fields_ be ISODateToFields(_calendar_, _monthDay_.[[ISODate]], ~month-day~). 1. Let _partialMonthDay_ be ? PrepareCalendarFields(_calendar_, _temporalMonthDayLike_, « ~year~, ~month~, ~month-code~, ~day~ », « », ~partial~). 1. Set _fields_ to CalendarMergeFields(_calendar_, _fields_, _partialMonthDay_). 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_). 1. Let _isoDate_ be ? CalendarMonthDayFromFields(_calendar_, _fields_, _overflow_). 1. Return ! CreateTemporalMonthDay(_isoDate_, _calendar_).

Temporal.PlainMonthDay.prototype.equals ( _other_ )

This method performs the following steps when called:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Set _other_ to ? ToTemporalMonthDay(_other_). 1. If CompareISODate(_monthDay_.[[ISODate]], _other_.[[ISODate]]) ≠ 0, return *false*. 1. Return CalendarEquals(_monthDay_.[[Calendar]], _other_.[[Calendar]]).

Temporal.PlainMonthDay.prototype.toString ( [ _options_ ] )

This method performs the following steps when called:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Let _showCalendar_ be ? GetTemporalShowCalendarNameOption(_resolvedOptions_). 1. Return TemporalMonthDayToString(_monthDay_, _showCalendar_).

Temporal.PlainMonthDay.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 _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Return TemporalMonthDayToString(_monthDay_, ~auto~).

Temporal.PlainMonthDay.prototype.toJSON ( )

This method performs the following steps when called:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. Return TemporalMonthDayToString(_monthDay_, ~auto~).

Temporal.PlainMonthDay.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 `plainMonthDay1 > plainMonthDay2` would fall back to being equivalent to `plainMonthDay1.toString() > plainMonthDay2.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()` on the corresponding `PlainDate` objects, `Temporal.PlainMonthDay.prototype.equals()`, and/or `Temporal.PlainMonthDay.prototype.toString()`.

Temporal.PlainMonthDay.prototype.toPlainDate ( _item_ )

This method performs the following steps when called:

1. Let _monthDay_ be the *this* value. 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). 1. If _item_ is not an Object, then 1. Throw a *TypeError* exception. 1. Let _calendar_ be _monthDay_.[[Calendar]]. 1. Let _fields_ be ISODateToFields(_calendar_, _monthDay_.[[ISODate]], ~month-day~). 1. Let _inputFields_ be ? PrepareCalendarFields(_calendar_, _item_, « ~year~ », « », « »). 1. Let _mergedFields_ be CalendarMergeFields(_calendar_, _fields_, _inputFields_). 1. Let _isoDate_ be ? CalendarDateFromFields(_calendar_, _mergedFields_, ~constrain~). 1. Return ! CreateTemporalDate(_isoDate_, _calendar_).

Properties of Temporal.PlainMonthDay Instances

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

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

Abstract Operations

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

description
Converts _item_ to a new Temporal.PlainMonthDay instance if possible, and throws otherwise.
1. If _options_ is not present, set _options_ to *undefined*. 1. If _item_ is a Object, then 1. If _item_ has an [[InitializedTemporalMonthDay]] internal slot, then 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Perform ? GetTemporalOverflowOption(_resolvedOptions_). 1. Return ! CreateTemporalMonthDay(_item_.[[ISODate]], _item_.[[Calendar]]). 1. Let _calendar_ be ? GetTemporalCalendarIdentifierWithISODefault(_item_). 1. Let _fields_ be ? PrepareCalendarFields(_calendar_, _item_, « ~year~, ~month~, ~month-code~, ~day~ », «», «»). 1. Let _resolvedOptions_ be ? GetOptionsObject(_options_). 1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_). 1. Let _isoDate_ be ? CalendarMonthDayFromFields(_calendar_, _fields_, _overflow_). 1. Return ! CreateTemporalMonthDay(_isoDate_, _calendar_). 1. If _item_ is not a String, throw a *TypeError* exception. 1. Let _result_ be ? ParseISODateTime(_item_, « |TemporalMonthDayString| »). 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. If _result_.[[Year]] is ~empty~, then 1. Assert: _calendar_ is *"iso8601"*. 1. Let _referenceISOYear_ be 1972 (the first ISO 8601 leap year after the epoch). 1. Let _isoDate_ be CreateISODateRecord(_referenceISOYear_, _result_.[[Month]], _result_.[[Day]]). 1. Return ! CreateTemporalMonthDay(_isoDate_, _calendar_). 1. Let _isoDate_ be CreateISODateRecord(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]). 1. Set _result_ to ISODateToFields(_calendar_, _isoDate_, ~month-day~). 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 [[Year]] field of the [[ISODate]] internal slot of the result. 1. Set _isoDate_ to ? CalendarMonthDayFromFields(_calendar_, _result_, ~constrain~). 1. Return ! CreateTemporalMonthDay(_isoDate_, _calendar_).

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

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

TemporalMonthDayToString ( _monthDay_: a Temporal.PlainMonthDay, _showCalendar_: ~auto~, ~always~, ~never~, or ~critical~, ): a String

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