test262/test/intl402/Temporal/Duration/compare/twenty-five-hour-day.js
Philip Chimento 7d970fbe4e Temporal: Remove fake West Coast and Samoa time zones from TemporalHelpers
It's no longer possible to fake built-in time zones using custom objects.
So testing DST shifts will have to use real built-in time zones. Replace
TemporalHelpers.springForwardFallBackTimeZone with America/Vancouver (it
was modelled on the DST transitions in 2000) and
TemporalHelpers.crossDateLineTimeZone with Pacific/Apia (it was modelled
on the 2011 switch to the other side of the international date line.)

These tests have to move to the intl402/ folder since non-Intl-aware
implementations are allowed (but not required) to support any built-in
time zones other than UTC.
2024-07-05 10:43:53 +02:00

31 lines
969 B
JavaScript

// 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 24 hours
features: [Temporal]
---*/
// 2000-10-29 is a 25-hour day according to this time zone...
const relativeTo = new Temporal.ZonedDateTime(941184000_000_000_000n, "America/Vancouver");
// confirm that we have rewound one year and one day:
assert.sameValue('1999-10-29T01:00:00-07:00[America/Vancouver]', 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"
);