Skip to content

Commit 73e73f3

Browse files
committed
Temporal: Add Duration.round() case triggering temporal_rs bug
I'm not sure of the exact circumstances that trigger this bug, but it seems to be balancing a duration to a larger unit while also rounding to an increment, with ZonedDateTime relativeTo. Discovered using snapshot testing. V8/Boa bug: boa-dev/temporal#689
1 parent d563437 commit 73e73f3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (C) 2026 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.round
6+
description: Test a specific buggy case from temporal_rs
7+
includes: [temporalHelpers.js]
8+
features: [Temporal]
9+
---*/
10+
11+
const d = new Temporal.Duration(0, 0, 0, 0, 48);
12+
const plainRelativeTo = new Temporal.PlainDate(2020, 1, 1);
13+
const zonedRelativeTo = new Temporal.ZonedDateTime(0n, "UTC");
14+
15+
for (const relativeTo of [undefined, plainRelativeTo, zonedRelativeTo]) {
16+
TemporalHelpers.assertDuration(d.round({
17+
smallestUnit: "days",
18+
roundingIncrement: 2,
19+
relativeTo
20+
}), 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, `with relativeTo ${relativeTo}`);
21+
}

0 commit comments

Comments
 (0)