Skip to content

Commit

Permalink
Editorial: Remove ToISODayOfWeek
Browse files Browse the repository at this point in the history
ECMA-262 already has a WeekDay equation. We had used some handwavy text in
ToISODayOfWeek about "the day of week according to ISO-8601" but this
change uses the logic already present in the spec.

See: #1641
  • Loading branch information
ptomato committed May 6, 2022
1 parent 9770d5a commit 2d1aae4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 5 additions & 13 deletions spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,18 +452,6 @@ <h1>ISODaysInMonth ( _year_, _month_ )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-toisodayofweek" aoid="ToISODayOfWeek">
<h1>ToISODayOfWeek ( _year_, _month_, _day_ )</h1>
<emu-alg>
1. Assert: _year_ is an integer.
1. Assert: _month_ is an integer.
1. Assert: _day_ is an integer.
1. Let _date_ be the date given by _year_, _month_, and _day_.
1. Return _date_'s day of the week according to ISO-8601 as an integer.
</emu-alg>
<emu-note>Monday is 1 and Sunday is 7.</emu-note>
</emu-clause>

<emu-clause id="sec-temporal-toisoweekofyear" aoid="ToISOWeekOfYear">
<h1>ToISOWeekOfYear ( _year_, _month_, _day_ )</h1>
<emu-alg>
Expand Down Expand Up @@ -959,7 +947,11 @@ <h1>Temporal.Calendar.prototype.dayOfWeek ( _temporalDateLike_ )</h1>
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Assert: _calendar_.[[Identifier]] is *"iso8601"*.
1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_).
1. Return 𝔽(! ToISODayOfWeek(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]])).
1. Let _epochDays_ be MakeDay(𝔽(_temporalDate_.[[ISOYear]]), 𝔽(_temporalDate_.[[ISOMonth]] - 1), 𝔽(_temporalDate_.[[ISODay]])).
1. Assert: _epochDays_ is finite.
1. Let _dayOfWeek_ be WeekDay(MakeDate(_epochDays_, *+0*<sub>𝔽</sub>)).
1. If _dayOfWeek_ = *+0*<sub>𝔽</sub>, return *7*<sub>𝔽</sub>.
1. Return _dayOfWeek_.
</emu-alg>
</emu-clause>

Expand Down
9 changes: 6 additions & 3 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1852,9 +1852,12 @@ <h1>Temporal.Calendar.prototype.dayOfWeek ( _dateOrDateTime_ )</h1>
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _dayOfWeek_ be ! ToISODayOfWeek(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]]).
1. Else,
1. Let _dayOfWeek_ be ! CalendarDateDayOfWeek(_calendar_.[[Identifier]], _temporalDate_).
1. Let _epochDays_ be MakeDay(𝔽(_temporalDate_.[[ISOYear]]), 𝔽(_temporalDate_.[[ISOMonth]] - 1), 𝔽(_temporalDate_.[[ISODay]])).
1. Assert: _epochDays_ is finite.
1. Let _dayOfWeek_ be WeekDay(MakeDate(_epochDays_, *+0*<sub>𝔽</sub>)).
1. If _dayOfWeek_ = *+0*<sub>𝔽</sub>, return *7*<sub>𝔽</sub>.
1. Return _dayOfWeek_.
1. Let _dayOfWeek_ be ! CalendarDateDayOfWeek(_calendar_.[[Identifier]], _temporalDate_).
1. Return 𝔽(_dayOfWeek_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 2d1aae4

Please sign in to comment.