From 4150c9e39debfc8acae9777e61e63b5d137464b0 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 10 Sep 2024 11:23:00 -0700 Subject: [PATCH] Editorial: Remove unnecessary CalendarDateFromFields from year-month 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. --- spec/plainyearmonth.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/plainyearmonth.html b/spec/plainyearmonth.html index f4d4e8ed9..b925921a3 100644 --- a/spec/plainyearmonth.html +++ b/spec/plainyearmonth.html @@ -759,10 +759,8 @@

1. If _sign_ < 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_).