Skip to content

Commit 678c434

Browse files
catamorphismMs2ger
authored andcommitted
Temporal: Add tests for correct rounding of epoch milliseconds in toString()
1 parent 18f6ed2 commit 678c434

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (C) 2025 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.instant.prototype.tostring
6+
description: Epoch milliseconds should be rounded down before adding negative micro/nanoseconds back in
7+
features: [BigInt, Temporal]
8+
---*/
9+
10+
const instant = new Temporal.Instant(-1000000000000001000n);
11+
assert.sameValue(instant.toString(), "1938-04-24T22:13:19.999999Z",
12+
"epoch milliseconds should be rounded down to compute seconds");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (C) 2025 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.plaindatetime.prototype.tostring
6+
description: Epoch milliseconds should be rounded down before adding negative micro/nanoseconds back in
7+
features: [Temporal]
8+
---*/
9+
10+
const pdt = new Temporal.PlainDateTime(1938, 4, 24, 22, 13, 19, 999, 999);
11+
assert.sameValue(pdt.toString(), "1938-04-24T22:13:19.999999",
12+
"epoch milliseconds should be rounded down to compute seconds");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (C) 2025 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.tostring
6+
description: Epoch milliseconds should be rounded down before adding negative micro/nanoseconds back in
7+
features: [BigInt, Temporal]
8+
---*/
9+
10+
const zdt = new Temporal.ZonedDateTime(-1000000000000001000n, "UTC");
11+
assert.sameValue(zdt.toString(), "1938-04-24T22:13:19.999999+00:00[UTC]",
12+
"epoch milliseconds should be rounded down to compute seconds");

0 commit comments

Comments
 (0)