Discovered thanks to Firefox fuzzing: https://bugzilla.mozilla.org/show_bug.cgi?id=2029455
Reproducer:
const relativeTo = Temporal.ZonedDateTime.from('2012-01-01T12:00:00[Pacific/Apia]');
const d = Temporal.Duration.from({ days: -1 });
d.round({ smallestUnit: 'days', relativeTo })
d.total({ unit: 'days', relativeTo });
const end = relativeTo.add(d);
relativeTo.until(end, { smallestUnit: 'days' })
All of these method calls (round, total, until) fail the assertion in NudgeToCalendarUnit, step 13: "Assert: startEpochNs ≠ endEpochNs." without which there would be a division by zero in step 14.
As we are well aware, there's a 24-hour UTC forward shift in the time zone Pacific/Apia, from 2011-12-29T23:59:99.999999 to 2011-12-31T00:00. The issue is that when determining the nudge window for rounding, even though both ends of the duration are outside of the time zone shift, the far bound of the nudge window (i.e. counting backwards 1 day from 2011-12-31T12:00) is inside it. So the far bound gets moved forward 1 day, putting it at the same instant as the near bound. The assertion assumes a zero-length nudge window should not be possible.
I'm not 100% sure what the results of the above calls should actually be. We should figure that out first, and then add test262 tests and adjust the assertion accordingly, since it is invalid.
Discovered thanks to Firefox fuzzing: https://bugzilla.mozilla.org/show_bug.cgi?id=2029455
Reproducer:
All of these method calls (
round,total,until) fail the assertion in NudgeToCalendarUnit, step 13: "Assert: startEpochNs ≠ endEpochNs." without which there would be a division by zero in step 14.As we are well aware, there's a 24-hour UTC forward shift in the time zone
Pacific/Apia, from 2011-12-29T23:59:99.999999 to 2011-12-31T00:00. The issue is that when determining the nudge window for rounding, even though both ends of the duration are outside of the time zone shift, the far bound of the nudge window (i.e. counting backwards 1 day from 2011-12-31T12:00) is inside it. So the far bound gets moved forward 1 day, putting it at the same instant as the near bound. The assertion assumes a zero-length nudge window should not be possible.I'm not 100% sure what the results of the above calls should actually be. We should figure that out first, and then add test262 tests and adjust the assertion accordingly, since it is invalid.