Skip to content

Commit

Permalink
Editorial: Remove 'default' optional parameter from ToTemporalCalenda…
Browse files Browse the repository at this point in the history
…rSlotValue

First change `ToTemporalMonthDay` to call `GetTemporalCalendarSlotValueWithISODefault`,
so the only place which uses the `default` optional parameter is
`GetTemporalCalendarSlotValueWithISODefault`. And then handle the `undefined` case
directly in `GetTemporalCalendarSlotValueWithISODefault`.

(Rebased by Philip: Rename SlotValue -> Identifier)
  • Loading branch information
anba authored and ptomato committed Aug 21, 2024
1 parent 573f4be commit 2b549d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 3 additions & 6 deletions spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -751,20 +751,15 @@ <h1>
<h1>
ToTemporalCalendarIdentifier (
_temporalCalendarLike_: an ECMAScript value,
optional _default_: a String,
): either a normal completion containing a String or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>
It attempts to derive a value from _temporalCalendarLike_ that is a calendar identifier according to IsBuiltinCalendar, and returns that value if found or throws an exception if not.
An optional _default_ built-in calendar identifier may be provided, which is returned if _temporalCalendarLike_ is *undefined*.
</dd>
</dl>
<emu-alg>
1. If _temporalCalendarLike_ is *undefined* and _default_ is present, then
1. Assert: IsBuiltinCalendar(_default_) is *true*.
1. Return _default_.
1. If _temporalCalendarLike_ is an Object, then
1. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
1. Return _temporalCalendarLike_.[[Calendar]].
Expand Down Expand Up @@ -792,7 +787,9 @@ <h1>
1. If _item_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
1. Return _item_.[[Calendar]].
1. Let _calendarLike_ be ? Get(_item_, *"calendar"*).
1. Return ? ToTemporalCalendarIdentifier(_calendarLike_, *"iso8601"*).
1. If _calendarLike_ is *undefined*, then
1. Return *"iso8601"*.
1. Return ? ToTemporalCalendarIdentifier(_calendarLike_).
</emu-alg>
</emu-clause>

Expand Down
6 changes: 1 addition & 5 deletions spec/plainmonthday.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,7 @@ <h1>
1. Set _options_ to ? GetOptionsObject(_options_).
1. Perform ? GetTemporalOverflowOption(_options_).
1. Return _item_.
1. If _item_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
1. Let _calendar_ be _item_.[[Calendar]].
1. Else,
1. Let _calendarLike_ be ? Get(_item_, *"calendar"*).
1. Let _calendar_ be ? ToTemporalCalendarIdentifier(_calendarLike_, *"iso8601"*).
1. Let _calendar_ be ? GetTemporalCalendarIdentifierWithISODefault(_item_).
1. Let _fields_ be ? PrepareCalendarFields(_calendar_, _item_, « ~day~, ~month~, ~month-code~, ~year~ », «», «»).
1. Set _options_ to ? GetOptionsObject(_options_).
1. Let _overflow_ be ? GetTemporalOverflowOption(_options_).
Expand Down

0 comments on commit 2b549d0

Please sign in to comment.