Skip to content

Commit 1e3d8cb

Browse files
committed
Add extra tests for newly fixed bug
1 parent 9671895 commit 1e3d8cb

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (C) 2024 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.zoneddatetime.prototype.since
6+
description: >
7+
Difference with the endpoint being the end of a skipped hour, chooses the
8+
smaller of two possible durations
9+
includes: [temporalHelpers.js]
10+
features: [Temporal]
11+
---*/
12+
13+
// Based on a test case by Adam Shaw
14+
15+
const timeZone = TemporalHelpers.springForwardFallBackTimeZone();
16+
17+
const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, timeZone);
18+
const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, timeZone);
19+
// NOTE: nonexistent hour just before d2
20+
21+
const result = d1.since(d2, { largestUnit: "months" });
22+
23+
TemporalHelpers.assertDuration(
24+
result, 0, 0, 0, 29, 23, 0, 0, 0, 0, 0,
25+
"Result should not balance up to months, but pick the smaller of two possible durations"
26+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (C) 2024 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.zoneddatetime.prototype.until
6+
description: >
7+
Difference with the endpoint being the end of a skipped hour, chooses the
8+
smaller of two possible durations
9+
includes: [temporalHelpers.js]
10+
features: [Temporal]
11+
---*/
12+
13+
// Based on a test case by Adam Shaw
14+
15+
const timeZone = TemporalHelpers.springForwardFallBackTimeZone();
16+
17+
const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, timeZone);
18+
const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, timeZone);
19+
// NOTE: nonexistent hour just before d2
20+
21+
const result = d1.until(d2, { largestUnit: "months" });
22+
23+
TemporalHelpers.assertDuration(
24+
result, 0, 0, 0, -29, -23, 0, 0, 0, 0, 0,
25+
"Result should not balance up to months, but pick the smaller of two possible durations"
26+
);

0 commit comments

Comments
 (0)