Temporal: Add test coverage for edge case in DST balancing after rounding

This covers an edge case that we hit, where 24 hours would not balance up
to one day in a 25-hour day if only largestUnit was specified, but would
erroneously balance up if rounding was also performed by specifying
smallestUnit.
This commit is contained in:
Philip Chimento 2024-05-13 15:35:23 -07:00 committed by Ms2ger
parent 500cea9384
commit a7e796a4ce
1 changed files with 17 additions and 0 deletions

View File

@ -22,3 +22,20 @@ const timeZone = TemporalHelpers.springForwardFallBackTimeZone();
TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 24, 0, 0, 0, 0, 0,
"24 hours does not balance to 1 day in 25-hour day");
}
{
const duration = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 24, 0, 0, 0, 0, /* ns = */ 5);
const relativeTo = new Temporal.ZonedDateTime(
972802800_000_000_000n /* = 2000-10-29T07Z */,
timeZone); /* = 2000-10-29T00-07 in local time */
const result = duration.round({
largestUnit: "days",
smallestUnit: "minutes",
roundingMode: "expand",
roundingIncrement: 30,
relativeTo
});
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 24, 30, 0, 0, 0, 0,
"24 hours does not balance after rounding to 1 day in 25-hour day");
}