Skip to content

Commit

Permalink
possible to omit calls to CalendarDay and CalendarDateFromFields when…
Browse files Browse the repository at this point in the history
… doing PlainYearMonth math
  • Loading branch information
arshaw authored and ptomato committed Sep 10, 2024
1 parent 5d67c89 commit c4cbcb0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4409,9 +4409,7 @@ export function AddDurationToOrSubtractDurationFromPlainYearMonth(operation, yea
let startDate = CalendarDateFromFields(calendar, fields, 'constrain');
if (sign < 0) {
const nextMonth = CalendarDateAdd(calendar, startDate, { months: 1 }, 'constrain');
const endOfMonth = BalanceISODate(nextMonth.year, nextMonth.month, nextMonth.day - 1);
fields.day = CalendarDay(calendar, endOfMonth);
startDate = CalendarDateFromFields(calendar, fields, 'constrain');
startDate = BalanceISODate(nextMonth.year, nextMonth.month, nextMonth.day - 1);
}
RejectDateRange(startDate.year, startDate.month, startDate.day);
const addedDate = CalendarDateAdd(calendar, startDate, { years, months, weeks, days }, overflow);
Expand Down

0 comments on commit c4cbcb0

Please sign in to comment.