forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
References: + tc39/proposal-temporal#1791 Thanks @ptomato for the suggestion to use `springForwardFallBackTimeZone`.
- Loading branch information
1 parent
b13789a
commit d9b8e4e
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
test/built-ins/Temporal/Duration/compare/twenty-five-hour-day.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.compare | ||
description: Unbalancing handles DST days with more than hours | ||
features: [Temporal] | ||
includes: [temporalHelpers.js] | ||
---*/ | ||
|
||
const tz = TemporalHelpers.springForwardFallBackTimeZone(); | ||
|
||
// 2000-10-29 is a 25-hour day according to this time zone... | ||
|
||
const relativeTo = new Temporal.ZonedDateTime(941187600_000_000_000n, tz); | ||
|
||
// confirm that we have rewound one year and one day: | ||
assert.sameValue('1999-10-29T01:00:00-08:00[Custom/Spring_Fall]', relativeTo.toString()); | ||
|
||
const d1 = new Temporal.Duration(1, 0, 0, 1); | ||
const d2 = new Temporal.Duration(1, 0, 0, 0, 25); | ||
|
||
// ...so the durations should be equal relative to relativeTo: | ||
|
||
assert.sameValue(0, | ||
Temporal.Duration.compare(d1, d2, { relativeTo }), | ||
"2000-10-29 is a 25-hour day" | ||
); | ||
|
||
assert.sameValue(1, | ||
Temporal.Duration.compare(d1, { years: 1, hours: 24 }, { relativeTo }), | ||
"2020-10-29 has more than 24 hours" | ||
); |