Temporal: Add test for date with offset transition (#4301)

Co-authored-by: Philip Chimento <philip.chimento@gmail.com>
This commit is contained in:
Tim Chevalier 2024-11-01 13:43:05 -07:00 committed by GitHub
parent 01eb47d4f2
commit ab69bd4dd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.hoursinday
description: Handles dates with offset transitions where midnight occurs twice.
features: [Temporal]
---*/
// Test date with offset transition where the same day starts twice
// See https://github.com/tc39/proposal-temporal/issues/2938 for more details
const zdt1 = Temporal.ZonedDateTime.from('2010-11-06T00:00:00-02:30[America/St_Johns]');
const zdt2 = Temporal.ZonedDateTime.from('2010-11-07T23:00:00-03:30[America/St_Johns]');
const zdt3 = Temporal.ZonedDateTime.from('2010-11-08T23:00:00-03:30[America/St_Johns]');
assert.sameValue(zdt1.hoursInDay, 24);
assert.sameValue(zdt2.hoursInDay, 25);
assert.sameValue(zdt3.hoursInDay, 24);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.startofday
description: Handles dates with offset transitions where midnight occurs twice.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// Test date with offset transition where the same day starts twice
// See https://github.com/tc39/proposal-temporal/issues/2938 for more details
const zdt1 = Temporal.ZonedDateTime.from('2010-11-06T00:00:00-02:30[America/St_Johns]');
const zdt2 = Temporal.ZonedDateTime.from('2010-11-07T23:00:00-03:30[America/St_Johns]');
const zdt3 = Temporal.ZonedDateTime.from('2010-11-08T23:00:00-03:30[America/St_Johns]');
const startOfDay2 = Temporal.ZonedDateTime.from('2010-11-07T00:00:00-02:30[America/St_Johns]');
const startOfDay3 = Temporal.ZonedDateTime.from('2010-11-08T00:00:00-03:30[America/St_Johns]');
TemporalHelpers.assertZonedDateTimesEqual(zdt1.startOfDay(), zdt1);
TemporalHelpers.assertZonedDateTimesEqual(zdt2.startOfDay(), startOfDay2);
TemporalHelpers.assertZonedDateTimesEqual(zdt3.startOfDay(), startOfDay3);