Skip to content

Commit

Permalink
Temporal: move tests for ZonedDateTime/p/{toInstant, toPlainDate, toP…
Browse files Browse the repository at this point in the history
…lainTime, toString}
  • Loading branch information
catamorphism authored and ptomato committed Oct 31, 2024
1 parent 7a4426e commit 731468f
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.toinstant
description: toInstant() works with a recent date.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

const zdt = Temporal.ZonedDateTime.from("2019-10-29T10:46:38.271986102+01:00[+01:00]");

TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("2019-10-29T09:46:38.271986102Z"));
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.toinstant
description: Year <= 1.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

var zdt = Temporal.ZonedDateTime.from("0000-10-29T10:46:38.271986102+00:00[UTC]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("0000-10-29T10:46:38.271986102Z"));

zdt = Temporal.ZonedDateTime.from("+000000-10-29T10:46:38.271986102+00:00[UTC]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("0000-10-29T10:46:38.271986102Z"));

zdt = Temporal.ZonedDateTime.from("-001000-10-29T10:46:38.271986102+00:00[UTC]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("-001000-10-29T10:46:38.271986102Z"));

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.toinstant
description: Year <= 99.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

var zdt = Temporal.ZonedDateTime.from("0098-10-29T10:46:38.271986102+00:00[UTC]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("0098-10-29T10:46:38.271986102Z"));

zdt = Temporal.ZonedDateTime.from("+000098-10-29T10:46:38.271986102+00:00[UTC]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("0098-10-29T10:46:38.271986102Z"));
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.toinstant
description: Year 0 leap day.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

var zdt = Temporal.ZonedDateTime.from("0000-02-29T00:00-00:01[-00:01]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("0000-02-29T00:01:00Z"));

zdt = Temporal.ZonedDateTime.from("+000000-02-29T00:00-00:01[-00:01]");
TemporalHelpers.assertInstantsEqual(
zdt.toInstant(),
Temporal.Instant.from("0000-02-29T00:01:00Z"));
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.toplaindate
description: toPlainDate() works as expected.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

const zdt = Temporal.ZonedDateTime.from("2019-10-29T09:46:38.271986102[-07:00]");

TemporalHelpers.assertPlainDate(zdt.toPlainDate(), 2019, 10, "M10", 29);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.toplaintime
description: toPlainTime() works as expected.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

const zdt = Temporal.ZonedDateTime.from("2019-10-29T09:46:38.271986102Z[-07:00]");

TemporalHelpers.assertPlainTime(zdt.toPlainTime(), 2, 46, 38, 271, 986, 102);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.tostring
description: Shows offset if offset = auto.
features: [Temporal]
---*/

const zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]");

assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]");
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.tostring
description: Omits offset if offset = never.
features: [Temporal]
---*/

const zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]");

assert.sameValue(zdt1.toString({ offset: "never" }), "1976-11-18T15:23:00[UTC]");
33 changes: 0 additions & 33 deletions test/staging/Temporal/ZonedDateTime/old/toInstant.js

This file was deleted.

12 changes: 0 additions & 12 deletions test/staging/Temporal/ZonedDateTime/old/toPlainDate.js

This file was deleted.

12 changes: 0 additions & 12 deletions test/staging/Temporal/ZonedDateTime/old/toPlainTime.js

This file was deleted.

16 changes: 0 additions & 16 deletions test/staging/Temporal/ZonedDateTime/old/toString.js

This file was deleted.

0 comments on commit 731468f

Please sign in to comment.