Skip to content

Commit 9079aee

Browse files
catamorphismMs2ger
authored andcommitted
[Temporal] Add coverage for ZonedDateTime offsets before 1883
Add test that adding/subtracting a large duration to a ZonedDateTime in the America/Vancouver time zone results in a ZonedDateTime with the correct offset (prior to the introduction of standard time zones). This provides coverage for a bug observed in GraalJS.
1 parent 8a188ce commit 9079aee

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2023 Justin Grant. 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.add
6+
description: Addition resulting in a pre-1883 date returns the correct offset
7+
features: [Temporal]
8+
---*/
9+
10+
const instance = Temporal.ZonedDateTime.from("2001-09-08T18:46:40-07:00[America/Vancouver]");
11+
const expectedOffset = "-08:12:28"; // Offset before introduction of standard time zones
12+
13+
assert.sameValue(instance.add(Temporal.Duration.from("-P5432Y1837M")).offset, expectedOffset, `add -P5432Y1837M, offset should be ${expectedOffset}`);
14+
assert.sameValue(instance.add(Temporal.Duration.from("-P5432Y1836M")).offset, expectedOffset, `add -P5432Y1836M, offset should be ${expectedOffset}`);
15+
assert.sameValue(instance.add(Temporal.Duration.from("-P5432Y1835M")).offset, expectedOffset, `add -P5432Y1835M, offset should be ${expectedOffset}`);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2023 Justin Grant. 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.subtract
6+
description: Subtraction resulting in a pre-1883 date returns the correct offset
7+
features: [Temporal]
8+
---*/
9+
10+
const instance = Temporal.ZonedDateTime.from("2001-09-08T18:46:40-07:00[America/Vancouver]");
11+
const expectedOffset = "-08:12:28"; // Offset before introduction of standard time zones
12+
13+
assert.sameValue(instance.subtract(Temporal.Duration.from("P5432Y1837M")).offset, expectedOffset, `subtract -P5432Y1837M, offset should be ${expectedOffset}`);
14+
assert.sameValue(instance.subtract(Temporal.Duration.from("P5432Y1836M")).offset, expectedOffset, `subtract -P5432Y1836M, offset should be ${expectedOffset}`);
15+
assert.sameValue(instance.subtract(Temporal.Duration.from("P5432Y1835M")).offset, expectedOffset, `subtract -P5432Y1835M, offset should be ${expectedOffset}`);

0 commit comments

Comments
 (0)