From 88ebc41e5b7679623fa040e05775cef44be02e33 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 12 Apr 2021 18:14:32 -0700 Subject: [PATCH] Make types consistent that Calendar methods are be called with Now that we have a fast-path conversion from PlainDateTime to PlainDate, it's no longer necessary to check for an [[ISOYear]] internal slot. Make sure it is consistent whether a particular Calendar method can be called with a Temporal.PlainYearMonth or Temporal.PlainMonthDay without triggering a conversion, if appropriate. The policy is that these Calendar methods can all be called with a PlainDate, and additionally some of them can be called with a PlainYearMonth and/or PlainMonthDay. Anything else gets passed through ToTemporalDate, which includes the fast path for PlainDateTime. See: #1428 --- polyfill/lib/calendar.mjs | 26 ++++--- spec/calendar.html | 121 ++++++++++++++-------------- spec/intl.html | 160 ++++++++++++++++++-------------------- 3 files changed, 155 insertions(+), 152 deletions(-) diff --git a/polyfill/lib/calendar.mjs b/polyfill/lib/calendar.mjs index f33b34318e..21c517eaf9 100644 --- a/polyfill/lib/calendar.mjs +++ b/polyfill/lib/calendar.mjs @@ -88,71 +88,73 @@ export class Calendar { } year(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].year(date); } month(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); if (ES.IsTemporalMonthDay(date)) throw new TypeError('use monthCode on PlainMonthDay instead'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].month(date); } monthCode(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date) && !ES.IsTemporalMonthDay(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].monthCode(date); } day(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalMonthDay(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].day(date); } era(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].era(date); } eraYear(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].eraYear(date); } dayOfWeek(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].dayOfWeek(date); } dayOfYear(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].dayOfYear(date); } weekOfYear(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].weekOfYear(date); } daysInWeek(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].daysInWeek(date); } daysInMonth(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].daysInMonth(date); } daysInYear(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].daysInYear(date); } monthsInYear(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); - if (!HasSlot(date, ISO_YEAR)) date = ES.ToTemporalDate(date); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].monthsInYear(date); } inLeapYear(date) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); + if (!ES.IsTemporalYearMonth(date)) date = ES.ToTemporalDate(date); return impl[GetSlot(this, CALENDAR_ID)].inLeapYear(date); } toString() { diff --git a/spec/calendar.html b/spec/calendar.html index 74fc787150..740fa41a6f 100644 --- a/spec/calendar.html +++ b/spec/calendar.html @@ -526,51 +526,47 @@

ISOMonthDayFromFields ( _fields_, _options_ )

-

ISOYear ( _dateOrDateTime_ )

+

ISOYear ( _temporalObject_ )

The ISOYear abstract operation implements the calendar-specific logic in the `Temporal.Calendar.year` method for the ISO 8601 calendar.

- 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(_dateOrDateTime_.[[ISOYear]]). + 1. Assert: _temporalObject_ has an [[ISOYear]] internal slot. + 1. Return 𝔽(_temporalObject_.[[ISOYear]]).
-

ISOMonth ( _dateOrDateTime_ )

+

ISOMonth ( _temporalObject_ )

The ISOMonth abstract operation implements the calendar-specific logic in the `Temporal.Calendar.month` method for the ISO 8601 calendar.

- 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOMonth]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(_dateOrDateTime_.[[ISOMonth]]). + 1. Assert: _temporalObject_ has an [[ISOMonth]] internal slot. + 1. Return 𝔽(_temporalObject_.[[ISOMonth]]).
-

ISOMonthCode ( _dateOrDateTime_ )

+

ISOMonthCode ( _temporalObject_ )

The ISOMonthCode abstract operation implements the calendar-specific logic in the `Temporal.Calendar.monthCode` method for the ISO 8601 calendar.

- 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOMonth]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _monthCode_ be the String representation of _dateOrDateTime_.[[ISOMonth]], formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary. + 1. Assert: _temporalObject_ has an [[ISOMonth]] internal slot. + 1. Let _monthCode_ be the String representation of _temporalObject_.[[ISOMonth]], formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary. 1. Return the string-concatenation of *"M"* and _monthCode_.
-

ISODay ( _dateOrDateTime_ )

+

ISODay ( _temporalObject_ )

The ISODay abstract operation implements the calendar-specific logic in the `Temporal.Calendar.day` method for the ISO 8601 calendar.

- 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISODay]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(_dateOrDateTime_.[[ISODay]]). + 1. Assert: _temporalObject_ has an [[ISODay]] internal slot. + 1. Return 𝔽(_temporalObject_.[[ISODay]]).
@@ -798,191 +794,200 @@

Temporal.Calendar.prototype.dateUntil ( _one_, _two_, _options_ )

-

Temporal.Calendar.prototype.year ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.year ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `year` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `year` method is used.

- The `year` method takes one argument _dateOrDateTime_. + The `year` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Return ? ISOYear(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return ! ISOYear(_temporalDateLike_).
-

Temporal.Calendar.prototype.month ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.month ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `month` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `month` method is used.

- The `month` method takes one argument _dateOrDateTime_. + The `month` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is Object and _dateOrDateTime_ has an [[InitializedTemporalMonthDay]] internal slot, then - 1. Throw a *TypeError* exception. 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Return ? ISOMonth(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is Object and _temporalDateLike_ has an [[InitializedTemporalMonthDay]] internal slot, then + 1. Throw a *TypeError* exception. + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return ! ISOMonth(_temporalDateLike_).
-

Temporal.Calendar.prototype.monthCode ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.monthCode ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `monthCode` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `monthCode` method is used.

- The `monthCode` method takes one argument _dateOrDateTime_. + The `monthCode` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Return ? ISOMonthCode(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]], [[InitializedTemporalMonthDay]], or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return ! ISOMonthCode(_temporalDateLike_).
-

Temporal.Calendar.prototype.day ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.day ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `day` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `day` method is used.

- The `day` method takes one argument _dateOrDateTime_. + The `day` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Return ? ISODay(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalMonthDay]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return ! ISODay(_temporalDateLike_).
-

Temporal.Calendar.prototype.dayOfWeek ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.dayOfWeek ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `dayOfWeek` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `dayOfWeek` method is used.

- The `dayOfWeek` method takes one argument _dateOrDateTime_. + The `dayOfWeek` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(! ToISODayOfWeek(_date_.[[ISOYear]], _date_.[[ISOMonth]], _date_.[[ISODay]])). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). + 1. Return 𝔽(! ToISODayOfWeek(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]])).
-

Temporal.Calendar.prototype.dayOfYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.dayOfYear ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `dayOfYear` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `dayOfYear` method is used.

- The `dayOfYear` method takes one argument _dateOrDateTime_. + The `dayOfYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(! ToISODayOfYear(_date_.[[ISOYear]], _date_.[[ISOMonth]], _date_.[[ISODay]])). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). + 1. Return 𝔽(! ToISODayOfYear(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]])).
-

Temporal.Calendar.prototype.weekOfYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.weekOfYear ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `weekOfYear` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `weekOfYear` method is used.

- The `weekOfYear` method takes one argument _dateOrDateTime_. + The `weekOfYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(! ToISOWeekOfYear(_date_.[[ISOYear]], _date_.[[ISOMonth]], _date_.[[ISODay]])). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). + 1. Return 𝔽(! ToISOWeekOfYear(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]])).
-

Temporal.Calendar.prototype.daysInWeek ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.daysInWeek ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `daysInWeek` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `daysInWeek` method is used.

- The `daysInWeek` method takes one argument _dateOrDateTime_. + The `daysInWeek` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Perform ? ToTemporalDate(_dateOrDateTime_). + 1. Perform ? ToTemporalDate(_temporalDateLike_). 1. Return *7*𝔽.
-

Temporal.Calendar.prototype.daysInMonth ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.daysInMonth ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `daysInMonth` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `daysInMonth` method is used.

- The `daysInMonth` method takes one argument _dateOrDateTime_. + The `daysInMonth` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. If _dateOrDateTime_ does not have [[ISOYear]] and [[ISOMonth]] internal slots, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Return 𝔽(! ISODaysInMonth(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]])). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slots, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return 𝔽(! ISODaysInMonth(_temporalDateLike_.[[ISOYear]], _temporalDateLike_.[[ISOMonth]])).
-

Temporal.Calendar.prototype.daysInYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.daysInYear ( _temporalDateLike_ )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the `daysInYear` method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the `daysInYear` method is used.

- The `daysInYear` method takes one argument _dateOrDateTime_. + The `daysInYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Let _year_ be ? ISOYear(_dateOrDateTime_). - 1. Return 𝔽(! ISODaysInYear(_year_)). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return 𝔽(! ISODaysInYear(_temporalDateLike_.[[ISOYear]])).
@@ -1000,7 +1005,8 @@

Temporal.Calendar.prototype.monthsInYear ( _dateOrDateTime_ )

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Perform ? ToTemporalDate(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Perform ? ToTemporalDate(_temporalDateLike_). 1. Return *12*𝔽. @@ -1019,8 +1025,9 @@

Temporal.Calendar.prototype.inLeapYear ( _dateOrDateTime_ )

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Assert: _calendar_.[[Identifier]] is *"iso8601"*. - 1. Let _year_ be ? ISOYear(_dateOrDateTime_). - 1. Return ! IsISOLeapYear(_year_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). + 1. Return ! IsISOLeapYear(_temporalDateLike_.[[ISOYear]]). diff --git a/spec/intl.html b/spec/intl.html index 4d1cdf0bac..03dd1b3697 100644 --- a/spec/intl.html +++ b/spec/intl.html @@ -1267,281 +1267,275 @@

Temporal.Calendar.prototype.dateUntil ( _one_, _two_, _options_ )

-

Temporal.Calendar.prototype.era ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.era ( _temporalDateLike_ )

- The `era` method takes one argument _dateOrDateTime_. + The `era` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then 1. Return *undefined*. - 1. Let _era_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _era_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return _era_.
-

Temporal.Calendar.prototype.eraYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.eraYear ( _temporalDateLike_ )

- The `eraYear` method takes one argument _dateOrDateTime_. + The `eraYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then 1. Return *undefined*. - 1. Let _eraYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _eraYear_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_eraYear_).
-

Temporal.Calendar.prototype.year ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.year ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `year` method takes one argument _dateOrDateTime_. + The `year` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _year_ be ? ISOYear(_dateOrDateTime_). + 1. Let _year_ be ! ISOYear(_temporalDateLike_). 1. Else, - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _year_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _year_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_year_).
-

Temporal.Calendar.prototype.month ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.month ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `month` method takes one argument _dateOrDateTime_. + The `month` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is Object and _dateOrDateTime_ has an [[InitializedTemporalMonthDay]] internal slot, then + 1. If Type(_temporalDateLike_) is Object and _temporalDateLike_ has an [[InitializedTemporalMonthDay]] internal slot, then 1. Throw a *TypeError* exception. + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _month_ be ? ISOMonth(_dateOrDateTime_). + 1. Let _month_ be ! ISOMonth(_temporalDateLike_). 1. Else, - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _month_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _month_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_month_).
-

Temporal.Calendar.prototype.monthCode ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.monthCode ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `monthCode` method takes one argument _dateOrDateTime_. + The `monthCode` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]], [[InitializedTemporalMonthDay]], or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _monthCode_ be ? ISOMonthCode(_dateOrDateTime_). + 1. Let _monthCode_ be ! ISOMonthCode(_temporalDateLike_). 1. Else, - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _monthCode_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _monthCode_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return _monthCode_.
-

Temporal.Calendar.prototype.day ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.day ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `day` method takes one argument _dateOrDateTime_. + The `day` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalMonthDay]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _day_ be ? ISODay(_dateOrDateTime_). + 1. Let _day_ be ! ISODay(_temporalDateLike_). 1. Else, - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _day_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _day_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_day_).

Temporal.Calendar.prototype.dayOfWeek ( _dateOrDateTime_ )

-

This definition supersedes the definition provided in .

+

This definition supersedes the definition _temporalDateLike_ in .

- The `dayOfWeek` method takes one argument _dateOrDateTime_. + The `dayOfWeek` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _dayOfWeek_ be ! ToISODayOfWeek(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]], _dateOrDateTime_.[[ISODay]]). + 1. Let _dayOfWeek_ be ! ToISODayOfWeek(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]]). 1. Else, - 1. Let _dayOfWeek_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _dayOfWeek_ be the result of implementation-defined processing of _temporalDate_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_dayOfWeek_).
-

Temporal.Calendar.prototype.dayOfYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.dayOfYear ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `dayOfYear` method takes one argument _dateOrDateTime_. + The `dayOfYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _dayOfYear_ be ! ToISODayOfYear(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]], _dateOrDateTime_.[[ISODay]]). + 1. Let _dayOfYear_ be ! ToISODayOfYear(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]]). 1. Else, - 1. Let _dayOfYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _dayOfYear_ be the result of implementation-defined processing of _temporalDate_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_dayOfYear_).
-

Temporal.Calendar.prototype.weekOfYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.weekOfYear ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `weekOfYear` method takes one argument _dateOrDateTime_. + The `weekOfYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _weekOfYear_ be ! ToISOWeekOfYear(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]], _dateOrDateTime_.[[ISODay]]). + 1. Let _weekOfYear_ be ! ToISOWeekOfYear(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]]). 1. Else, - 1. Let _weekOfYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _weekOfYear_ be the result of implementation-defined processing of _temporalDate_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_weekOfYear_).
-

Temporal.Calendar.prototype.daysInWeek ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.daysInWeek ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `daysInWeek` method takes one argument _dateOrDateTime_. + The `daysInWeek` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then 1. Let _daysInWeek_ be 7. 1. Else, - 1. Let _daysInWeek_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _daysInWeek_ be the result of implementation-defined processing of _temporalDate_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_daysInWeek_).
-

Temporal.Calendar.prototype.daysInMonth ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.daysInMonth ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `daysInMonth` method takes one argument _dateOrDateTime_. + The `daysInMonth` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slots, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _daysInMonth_ be ! ISODaysInMonth(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]]). + 1. Let _daysInMonth_ be ! ISODaysInMonth(_temporalDateLike_.[[ISOYear]], _temporalDateLike_.[[ISOMonth]]). 1. Else, - 1. Let _daysInMonth_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _daysInMonth_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_daysInMonth_).
-

Temporal.Calendar.prototype.daysInYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.daysInYear ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `daysInYear` method takes one argument _dateOrDateTime_. + The `daysInYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _year_ be ? ISOYear(_dateOrDateTime_). - 1. Let _daysInYear_ be ! ISODaysInYear(_year_). + 1. Let _daysInYear_ be ! ISODaysInYear(_temporalDateLike_.[[ISOYear]]). 1. Else, - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _daysInYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _daysInYear_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_daysInYear_).
-

Temporal.Calendar.prototype.monthsInYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.monthsInYear ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `monthsInYear` method takes one argument _dateOrDateTime_. + The `monthsInYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then 1. Let _monthsInYear_ be 12. 1. Else, - 1. Let _monthsInYear_ be the result of implementation-defined processing of _date_ and the value of _calendar_.[[Identifier]]. + 1. Let _monthsInYear_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return 𝔽(_monthsInYear_).
-

Temporal.Calendar.prototype.inLeapYear ( _dateOrDateTime_ )

+

Temporal.Calendar.prototype.inLeapYear ( _temporalDateLike_ )

This definition supersedes the definition provided in .

- The `inLeapYear` method takes one argument _dateOrDateTime_. + The `inLeapYear` method takes one argument _temporalDateLike_. The following steps are taken:

1. Let _calendar_ be the *this* value. 1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). + 1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + 1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_). 1. If _calendar_.[[Identifier]] is *"iso8601"*, then - 1. Let _year_ be ? ISOYear(_dateOrDateTime_). - 1. Let _inLeapYear_ be ! IsISOLeapYear(_year_). + 1. Let _inLeapYear_ be ! IsISOLeapYear(_temporalDateLike_.[[ISOYear]]). 1. Else, - 1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then - 1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - 1. Let _inLeapYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]]. + 1. Let _inLeapYear_ be the result of implementation-defined processing of _temporalDateLike_ and the value of _calendar_.[[Identifier]]. 1. Return _inLeapYear_.