From 22e454809e0ac95dcfe08278ea4e444b5763e2d6 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 13 May 2024 15:35:23 -0700 Subject: [PATCH] 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. --- .../prototype/round/dst-balancing-result.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js b/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js index 40b360238f8..b0f97a02742 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js +++ b/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js @@ -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"); +}