Skip to content

Commit

Permalink
Temporal: Port staging tests that use next/previousTransition
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Jun 13, 2024
1 parent 5d6954b commit b6aeb3c
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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.gettimezonetransition
description: An offset time zone has no transitions.
features: [Temporal]
---*/

const zdt = new Temporal.ZonedDateTime(0n, "-10:00");
assert.sameValue(zdt.getTimeZoneTransition("next"), null, "An offset time zone has no next transition");
assert.sameValue(zdt.getTimeZoneTransition("previous"), null, "An offset time zone has no previous transition");
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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.gettimezonetransition
description: The UTC time zone has no transitions.
features: [Temporal]
---*/

const zdt = new Temporal.ZonedDateTime(0n, "UTC");
assert.sameValue(zdt.getTimeZoneTransition("next"), null, "The UTC time zone has no next transition");
assert.sameValue(zdt.getTimeZoneTransition("previous"), null, "The UTC time zone has no previous transition");
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.gettimezonetransition
description: Next and previous transition in a named time zone has the correct return type
features: [Temporal]
---*/

let zdt = new Temporal.ZonedDateTime(0n, "America/Los_Angeles");
for (let count = 0; count < 4; count++) {
const transition = zdt.getTimeZoneTransition("next");
assert(transition instanceof Temporal.ZonedDateTime, "getTimeZoneTransition(next) returns Temporal.ZonedDateTime");
assert(!transition.equals(zdt), "getTimeZoneTransition(next) does not return its input");
zdt = transition;
}

zdt = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "America/Los_Angeles");
for (let count = 0; count < 4; count++) {
const transition = zdt.getTimeZoneTransition("previous");
assert(transition instanceof Temporal.ZonedDateTime, "getTimeZoneTransition(previous) returns Temporal.ZonedDateTime");
assert(!transition.equals(zdt), "getTimeZoneTransition(previous) does not return its input");
zdt = transition;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.gettimezonetransition
description: Smoke test specific values from time zone database
includes: [temporalHelpers.js]
features: [Temporal]
---*/

const a1 = new Temporal.ZonedDateTime(1555448460_000_000_000n /* = 2019-04-16T21:01Z */, "America/New_York");
assert.sameValue(a1.getTimeZoneTransition("next").epochNanoseconds, 1572760800_000_000_000n /* = 2019-11-03T06:00:00Z */);

const a2 = new Temporal.ZonedDateTime(-5364662400_000_000_000n /* = 1800-01-01T00:00Z */, "America/New_York");
assert.sameValue(a2.getTimeZoneTransition("next").epochNanoseconds, -2717650800_000_000_000n /* = 1883-11-18T17:00:00Z */);

const a3 = new Temporal.ZonedDateTime(1591909260_000_000_000n /* = 2020-06-11T21:01Z */, "Europe/London");
assert.sameValue(a3.getTimeZoneTransition("previous").epochNanoseconds, 1585443600_000_000_000n /* = 2020-03-29T01:00:00Z */);

const a4 = new Temporal.ZonedDateTime(-3849984000_000_000_000n /* = 1848-01-01T00:00Z */, "Europe/London");
assert.sameValue(a4.getTimeZoneTransition("previous").epochNanoseconds, -3852662325_000_000_000n, /* = 1847-12-01T00:01:15Z */);
12 changes: 0 additions & 12 deletions test/staging/Intl402/Temporal/old/timezone-america-la.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,3 @@ assert.sameValue(zone.id, `${ zone }`)
assert.sameValue(zone.getOffsetNanosecondsFor(inst), -8 * 3600000000000)
assert.sameValue(zone.getOffsetStringFor(inst), "-08:00")
assert(zone.getInstantFor(dtm) instanceof Temporal.Instant)
for (var i = 0, txn = inst; i < 4; i++) {
var transition = zone.getNextTransition(txn);
assert(transition instanceof Temporal.Instant);
assert(!transition.equals(txn));
txn = transition;
}
for (var i = 0, txn = inst; i < 4; i++) {
var transition = zone.getPreviousTransition(txn);
assert(transition instanceof Temporal.Instant);
assert(!transition.equals(txn));
txn = transition;
}
44 changes: 0 additions & 44 deletions test/staging/Intl402/Temporal/old/tzdb-transitions.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/staging/Temporal/TimeZone/old/getNextTransition.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/staging/Temporal/TimeZone/old/getPreviousTransition.js

This file was deleted.

2 changes: 0 additions & 2 deletions test/staging/Temporal/TimeZone/old/timezone-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ assert.sameValue(zone.id, `${ zone }`)
assert.sameValue(zone.getOffsetNanosecondsFor(inst), 3600000000000)
assert(zone.getPlainDateTimeFor(inst) instanceof Temporal.PlainDateTime)
assert(zone.getInstantFor(dtm) instanceof Temporal.Instant)
assert.sameValue(zone.getNextTransition(inst), null)
assert.sameValue(zone.getPreviousTransition(inst), null)

// wraps around to the next day
assert.sameValue(`${ zone.getPlainDateTimeFor(Temporal.Instant.from("2020-02-06T23:59Z")) }`, "2020-02-07T00:59:00")
2 changes: 0 additions & 2 deletions test/staging/Temporal/TimeZone/old/timezone-utc-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ assert.sameValue(zone.id, `${ zone }`)
assert.sameValue(zone.getOffsetNanosecondsFor(inst), 0)
assert(zone.getPlainDateTimeFor(inst) instanceof Temporal.PlainDateTime)
assert(zone.getInstantFor(dtm) instanceof Temporal.Instant)
assert.sameValue(zone.getNextTransition(inst), null)
assert.sameValue(zone.getPreviousTransition(inst), null)

0 comments on commit b6aeb3c

Please sign in to comment.