Skip to content

Commit

Permalink
Editorial: Remove unnecessary CalendarDateFromFields from year-month …
Browse files Browse the repository at this point in the history
…addition

Spec text algorithm corresponding to the previous commit. There is no need
to convert the end-of-month ISO date to a calendar date and then back to
an ISO date.

This looks like it might have removed an observable step, but I think
CalendarDateFromFields could already not throw here, because of the
assertion that _endOfMonth_ was a valid ISO date within range.
  • Loading branch information
ptomato committed Sep 10, 2024
1 parent c4cbcb0 commit 4150c9e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,8 @@ <h1>
1. If _sign_ &lt; 0, then
1. Let _oneMonthDuration_ be ! CreateDateDurationRecord(0, 1, 0, 0).
1. Let _nextMonth_ be ? CalendarDateAdd(_calendar_, _intermediateDate_, _oneMonthDuration_, *"constrain"*).
1. Let _endOfMonth_ be BalanceISODate(_nextMonth_.[[Year]], _nextMonth_.[[Month]], _nextMonth_.[[Day]] - 1).
1. Assert: ISODateWithinLimits(_endOfMonth_.[[Year]], _endOfMonth_.[[Month]], _endOfMonth_.[[Day]]) is *true*.
1. Set _fields_.[[Day]] to CalendarDay(_calendar_, _endOfMonth_).
1. Let _date_ be ? CalendarDateFromFields(_calendar_, _fields_, *"constrain"*).
1. Let _date_ be BalanceISODate(_nextMonth_.[[Year]], _nextMonth_.[[Month]], _nextMonth_.[[Day]] - 1).
1. Assert: ISODateWithinLimits(_date_.[[Year]], _date_.[[Month]], _date_.[[Day]]) is *true*.
1. Else,
1. Let _date_ be _intermediateDate_.
1. Let _durationToAdd_ be ? CreateDateDurationRecord(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _days_).
Expand Down

0 comments on commit 4150c9e

Please sign in to comment.