Skip to content

Commit

Permalink
Fix bug where PlainDateTime since/until would maintain date/time-diff…
Browse files Browse the repository at this point in the history
… sign compatibility by backing-off from wrong end and erroneously falling across month boundaries
  • Loading branch information
arshaw committed May 14, 2024
1 parent c0be58d commit 20790d7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3879,8 +3879,10 @@ export function DifferenceISODateTime(

const timeSign = timeDuration.sign();
const dateSign = CompareISODate(y2, mon2, d2, y1, mon1, d1);

// back-off a day from date2 so that the signs of the date a time diff match
if (dateSign === -timeSign) {
({ year: y1, month: mon1, day: d1 } = BalanceISODate(y1, mon1, d1 - timeSign));
({ year: y2, month: mon2, day: d2 } = BalanceISODate(y2, mon2, d2 + timeSign));
timeDuration = timeDuration.add24HourDays(-timeSign);
}

Expand Down

0 comments on commit 20790d7

Please sign in to comment.