Skip to content

Commit

Permalink
Editorial: Move era/eraYear into 262 portion of spec
Browse files Browse the repository at this point in the history
This should have been part of #2193 but was forgotten. If a non-402
implementation is allowed to support more than just the iso8601 calendar,
then it will need to have era/eraYear properties.
  • Loading branch information
ptomato authored and Ms2ger committed May 2, 2024
1 parent 3866bea commit e1ed2eb
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 159 deletions.
75 changes: 75 additions & 0 deletions spec/calendar.html
Expand Up @@ -441,6 +441,51 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-calendarera" type="abstract operation">
<h1>
CalendarEra (
_calendar_: a String or Object,
_dateLike_: a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth,
): either a normal completion containing either a String or *undefined*, or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It calls the given _calendar_'s `era()` method and validates the result.</dd>
</dl>
<emu-alg>
1. If _calendar_ is a String, then
1. Set _calendar_ to ! CreateTemporalCalendar(_calendar_).
1. Return ! Call(%Temporal.Calendar.prototype.era%, _calendar_, « _dateLike_ »).
1. Let _result_ be ? Invoke(_calendar_, *"era"*, « _dateLike_ »).
1. If _result_ is *undefined*, return *undefined*.
1. If Type(_result_) is not String, throw a *TypeError* exception.
1. Return _result_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-calendarerayear" type="abstract operation">
<h1>
CalendarEraYear (
_calendar_: a String or Object,
_dateLike_: a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth,
): either a normal completion containing either an integer or *undefined*, or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It calls the given _calendar_'s `eraYear()` method and validates the result.</dd>
</dl>
<emu-alg>
1. If _calendar_ is a String, then
1. Set _calendar_ to ! CreateTemporalCalendar(_calendar_).
1. Return ! Call(%Temporal.Calendar.prototype.eraYear%, _calendar_, « _dateLike_ »).
1. Let _result_ be ? Invoke(_calendar_, *"eraYear"*, « _dateLike_ »).
1. If _result_ is *undefined*, return *undefined*.
1. If Type(_result_) is not Number, throw a *TypeError* exception.
1. If IsIntegralNumber(_result_) is *false*, throw a *RangeError* exception.
1. Return ℝ(_result_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-calendaryear" type="abstract operation">
<h1>
CalendarYear (
Expand Down Expand Up @@ -1463,6 +1508,36 @@ <h1>Temporal.Calendar.prototype.dateUntil ( _one_, _two_ [ , _options_ ] )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.calendar.prototype.era">
<h1>Temporal.Calendar.prototype.era ( _temporalDateLike_ )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Assert: _calendar_.[[Identifier]] is *"iso8601"*.
1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], or [[InitializedTemporalYearMonth]] internal slot, then
1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_).
1. Return *undefined*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.calendar.prototype.erayear">
<h1>Temporal.Calendar.prototype.eraYear ( _temporalDateLike_ )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Assert: _calendar_.[[Identifier]] is *"iso8601"*.
1. If Type(_temporalDateLike_) is not Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], or [[InitializedTemporalYearMonth]] internal slot, then
1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_).
1. Return *undefined*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.calendar.prototype.year">
<h1>Temporal.Calendar.prototype.year ( _temporalDateLike_ )</h1>
<p>
Expand Down
163 changes: 4 additions & 159 deletions spec/intl.html
Expand Up @@ -1753,45 +1753,6 @@ <h1><a href="https://tc39.es/ecma402/#locale-sensitive-functions">Locale Sensiti
<emu-clause id="sup-temporal-calendar-abstract-ops">
<h1>Abstract Operations for Temporal.Calendar Objects</h1>

<emu-clause id="sec-temporal-calendarera" type="abstract operation">
<h1>
CalendarEra (
_calendar_: an Object,
_dateLike_: a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth,
): either a normal completion containing either a String or *undefined*, or an abrupt completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It calls the given _calendar_'s `era()` method and validates the result.</dd>
</dl>
<emu-alg>
1. Let _result_ be ? Invoke(_calendar_, *"era"*, « _dateLike_ »).
1. If _result_ is *undefined*, return *undefined*.
1. If Type(_result_) is not String, throw a *TypeError* exception.
1. Return _result_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-calendarerayear" type="abstract operation">
<h1>
CalendarEraYear (
_calendar_: an Object,
_dateLike_: a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth,
): either a normal completion containing either an integer or *undefined*, or an abrupt completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It calls the given _calendar_'s `eraYear()` method and validates the result.</dd>
</dl>
<emu-alg>
1. Let _result_ be ? Invoke(_calendar_, *"eraYear"*, « _dateLike_ »).
1. If _result_ is *undefined*, return *undefined*.
1. If Type(_result_) is not Number, throw a *TypeError* exception.
1. If IsIntegralNumber(_result_) is *false*, throw a *RangeError* exception.
1. Return ℝ(_result_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-calendardatetoiso" type="implementation-defined abstract operation">
<h1>
CalendarDateToISO (
Expand Down Expand Up @@ -2354,8 +2315,9 @@ <h1>Temporal.Calendar.prototype.dateUntil ( _one_, _two_ [ , _options_ ] )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.calendar.prototype.era">
<emu-clause id="sup-temporal.calendar.prototype.era">
<h1>Temporal.Calendar.prototype.era ( _temporalDateLike_ )</h1>
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal.calendar.prototype.era"></emu-xref>.</p>
<p>
This method performs the following steps when called:
</p>
Expand All @@ -2370,8 +2332,9 @@ <h1>Temporal.Calendar.prototype.era ( _temporalDateLike_ )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.calendar.prototype.erayear">
<emu-clause id="sup-temporal.calendar.prototype.erayear">
<h1>Temporal.Calendar.prototype.eraYear ( _temporalDateLike_ )</h1>
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal.calendar.prototype.erayear"></emu-xref>.</p>
<p>
This method performs the following steps when called:
</p>
Expand Down Expand Up @@ -2750,34 +2713,6 @@ <h1>Temporal.PlainDate.prototype.toLocaleString ( [ _locales_ [ , _options_ ] ]
1. Return ? FormatDateTime(_dateFormat_, _temporalDate_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindate.prototype.era">
<h1>get Temporal.PlainDate.prototype.era</h1>
<p>
`Temporal.PlainDate.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be _plainDate_.[[Calendar]].
1. Return ? CalendarEra(_calendar_, _plainDate_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindate.prototype.erayear">
<h1>get Temporal.PlainDate.prototype.eraYear</h1>
<p>
`Temporal.PlainDate.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be _plainDate_.[[Calendar]].
1. Return ? CalendarEraYear(_calendar_, _plainDate_).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sup-properties-of-the-temporal-plaindatetime-prototype-object">
Expand All @@ -2795,34 +2730,6 @@ <h1>Temporal.PlainDateTime.prototype.toLocaleString ( [ _locales_ [ , _options_
1. Return ? FormatDateTime(_dateFormat_, _dateTime_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindatetime.prototype.era">
<h1>get Temporal.PlainDateTime.prototype.era</h1>
<p>
`Temporal.PlainDate.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDateTime_, [[InitializedTemporalDateTime]]).
1. Let _calendar_ be _plainDateTime_.[[Calendar]].
1. Return ? CalendarEra(_calendar_, _plainDateTime_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindatetime.prototype.erayear">
<h1>get Temporal.PlainDateTime.prototype.eraYear</h1>
<p>
`Temporal.PlainDateTime.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDateTime_, [[InitializedTemporalDateTime]]).
1. Let _calendar_ be _plainDateTime_.[[Calendar]].
1. Return ? CalendarEraYear(_calendar_, _plainDateTime_).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sup-properties-of-the-temporal-plainmonthday-prototype-object">
Expand Down Expand Up @@ -2874,34 +2781,6 @@ <h1>Temporal.PlainYearMonth.prototype.toLocaleString ( [ _locales_ [ , _options_
1. Return ? FormatDateTime(_dateFormat_, _yearMonth_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plainyearmonth.prototype.era">
<h1>get Temporal.PlainYearMonth.prototype.era</h1>
<p>
`Temporal.PlainYearMonth.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainYearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainYearMonth_, [[InitializedTemporalYearMonth]]).
1. Let _calendar_ be _plainYearMonth_.[[Calendar]].
1. Return ? CalendarEra(_calendar_, _plainYearMonth_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plainyearmonth.prototype.erayear">
<h1>get Temporal.PlainYearMonth.prototype.eraYear</h1>
<p>
`Temporal.PlainYearMonth.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainYearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainYearMonth_, [[InitializedTemporalYearMonth]]).
1. Let _calendar_ be _plainYearMonth_.[[Calendar]].
1. Return ? CalendarEraYear(_calendar_, _plainYearMonth_).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sup-properties-of-the-temporal-zoneddatetime-prototype-object">
Expand Down Expand Up @@ -2929,40 +2808,6 @@ <h1>Temporal.ZonedDateTime.prototype.toLocaleString ( [ _locales_ [ , _options_
1. Return ? FormatDateTime(_dateTimeFormat_, _instant_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.zoneddatetime.prototype.era">
<h1>get Temporal.ZonedDateTime.prototype.era</h1>
<p>
`Temporal.ZonedDateTime.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Let _instant_ be ! CreateTemporalInstant(_zonedDateTime_.[[Nanoseconds]]).
1. Let _calendar_ be _zonedDateTime_.[[Calendar]].
1. Let _timeZoneRec_ be ? CreateTimeZoneMethodsRecord(_zonedDateTime_.[[TimeZone]], « ~get-offset-nanoseconds-for~ »).
1. Let _plainDateTime_ be ? GetPlainDateTimeFor(_timeZoneRec_, _instant_, _calendar_).
1. Return ? CalendarEra(_calendar_, _plainDateTime_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.zoneddatetime.prototype.erayear">
<h1>get Temporal.ZonedDateTime.prototype.eraYear</h1>
<p>
`Temporal.ZonedDateTime.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Let _instant_ be ! CreateTemporalInstant(_zonedDateTime_.[[Nanoseconds]]).
1. Let _calendar_ be _zonedDateTime_.[[Calendar]].
1. Let _timeZoneRec_ be ? CreateTimeZoneMethodsRecord(_zonedDateTime_.[[TimeZone]], « ~get-offset-nanoseconds-for~ »).
1. Let _plainDateTime_ be ? GetPlainDateTimeFor(_timeZoneRec_, _instant_, _calendar_).
1. Return ? CalendarEraYear(_calendar_, _plainDateTime_).
</emu-alg>
</emu-clause>
</emu-clause>
</ins>
</emu-clause>
Expand Down
28 changes: 28 additions & 0 deletions spec/plaindate.html
Expand Up @@ -124,6 +124,34 @@ <h1>get Temporal.PlainDate.prototype.calendarId</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindate.prototype.era">
<h1>get Temporal.PlainDate.prototype.era</h1>
<p>
`Temporal.PlainDate.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be _plainDate_.[[Calendar]].
1. Return ? CalendarEra(_calendar_, _plainDate_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindate.prototype.erayear">
<h1>get Temporal.PlainDate.prototype.eraYear</h1>
<p>
`Temporal.PlainDate.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDate_, [[InitializedTemporalDate]]).
1. Let _calendar_ be _plainDate_.[[Calendar]].
1. Return ? CalendarEraYear(_calendar_, _plainDate_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindate.prototype.year">
<h1>get Temporal.PlainDate.prototype.year</h1>
<p>
Expand Down
28 changes: 28 additions & 0 deletions spec/plaindatetime.html
Expand Up @@ -127,6 +127,34 @@ <h1>get Temporal.PlainDateTime.prototype.calendarId</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindatetime.prototype.era">
<h1>get Temporal.PlainDateTime.prototype.era</h1>
<p>
`Temporal.PlainDate.prototype.era` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDateTime_, [[InitializedTemporalDateTime]]).
1. Let _calendar_ be _plainDateTime_.[[Calendar]].
1. Return ? CalendarEra(_calendar_, _plainDateTime_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindatetime.prototype.erayear">
<h1>get Temporal.PlainDateTime.prototype.eraYear</h1>
<p>
`Temporal.PlainDateTime.prototype.eraYear` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
</p>
<emu-alg>
1. Let _plainDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_plainDateTime_, [[InitializedTemporalDateTime]]).
1. Let _calendar_ be _plainDateTime_.[[Calendar]].
1. Return ? CalendarEraYear(_calendar_, _plainDateTime_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-temporal.plaindatetime.prototype.year">
<h1>get Temporal.PlainDateTime.prototype.year</h1>
<p>
Expand Down

0 comments on commit e1ed2eb

Please sign in to comment.