Skip to content

Commit

Permalink
Editorial: Remove ToISODayOfYear
Browse files Browse the repository at this point in the history
ECMA-262 already has a DayWithinYear equation. We had used some handwavy
text in ToISODayOfYear about "the ordinal date in the year according to
ISO-8601" but this change uses the logic already present in the spec.

See: #1641
  • Loading branch information
ptomato authored and Ms2ger committed May 6, 2022
1 parent a36bdd4 commit 6117d90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
15 changes: 3 additions & 12 deletions spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -464,17 +464,6 @@ <h1>ToISODayOfWeek ( _year_, _month_, _day_ )</h1>
<emu-note>Monday is 1 and Sunday is 7.</emu-note>
</emu-clause>

<emu-clause id="sec-temporal-toisodayofyear" aoid="ToISODayOfYear">
<h1>ToISODayOfYear ( _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 ordinal date in the year according to ISO-8601 as an integer.
</emu-alg>
</emu-clause>

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

Expand Down
7 changes: 4 additions & 3 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1871,9 +1871,10 @@ <h1>Temporal.Calendar.prototype.dayOfYear ( _temporalDateLike_ )</h1>
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _dayOfYear_ be ! ToISODayOfYear(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]]).
1. Else,
1. Let _dayOfYear_ be ! CalendarDateDayOfYear(_calendar_.[[Identifier]], _temporalDate_).
1. Let _epochDays_ be MakeDay(𝔽(_temporalDate_.[[ISOYear]]), 𝔽(_temporalDate_.[[ISOMonth]] - 1), 𝔽(_temporalDate_.[[ISODay]])).
1. Assert: _epochDays_ is finite.
1. Return DayWithinYear(MakeDate(_epochDays_, *+0*<sub>𝔽</sub>)).
1. Let _dayOfYear_ be ! CalendarDateDayOfYear(_calendar_.[[Identifier]], _temporalDate_).
1. Return 𝔽(_dayOfYear_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 6117d90

Please sign in to comment.