diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/recent-date.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/recent-date.js new file mode 100644 index 0000000000..afa1305336 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/recent-date.js @@ -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")); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-1.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-1.js new file mode 100644 index 0000000000..f91687c504 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-1.js @@ -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")); + diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-99.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-99.js new file mode 100644 index 0000000000..f9bca23aa4 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-99.js @@ -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")); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-zero-leap-day.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-zero-leap-day.js new file mode 100644 index 0000000000..adf658e7ae --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-zero-leap-day.js @@ -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")); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/basic.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/basic.js new file mode 100644 index 0000000000..e56fffcdc8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/basic.js @@ -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); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/basic.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/basic.js new file mode 100644 index 0000000000..6b645663d6 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/basic.js @@ -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); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-auto.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-auto.js new file mode 100644 index 0000000000..13e4a19aa8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-auto.js @@ -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]"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-never.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-never.js new file mode 100644 index 0000000000..da34d503d7 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-never.js @@ -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]"); diff --git a/test/staging/Temporal/ZonedDateTime/old/toInstant.js b/test/staging/Temporal/ZonedDateTime/old/toInstant.js deleted file mode 100644 index 32a3061f06..0000000000 --- a/test/staging/Temporal/ZonedDateTime/old/toInstant.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Temporal.ZonedDateTime.prototype.toInstant() -features: [Temporal] ----*/ - - -// recent date -var zdt = Temporal.ZonedDateTime.from("2019-10-29T10:46:38.271986102+01:00[+01:00]"); -assert.sameValue(`${ zdt.toInstant() }`, "2019-10-29T09:46:38.271986102Z"); - -// year ≤ 99 -var zdt = Temporal.ZonedDateTime.from("0098-10-29T10:46:38.271986102+00:00[UTC]"); -assert.sameValue(`${ zdt.toInstant() }`, "0098-10-29T10:46:38.271986102Z"); -zdt = Temporal.ZonedDateTime.from("+000098-10-29T10:46:38.271986102+00:00[UTC]"); -assert.sameValue(`${ zdt.toInstant() }`, "0098-10-29T10:46:38.271986102Z"); - -// year < 1 -var zdt = Temporal.ZonedDateTime.from("0000-10-29T10:46:38.271986102+00:00[UTC]"); -assert.sameValue(`${ zdt.toInstant() }`, "0000-10-29T10:46:38.271986102Z"); -zdt = Temporal.ZonedDateTime.from("+000000-10-29T10:46:38.271986102+00:00[UTC]"); -assert.sameValue(`${ zdt.toInstant() }`, "0000-10-29T10:46:38.271986102Z"); -zdt = Temporal.ZonedDateTime.from("-001000-10-29T10:46:38.271986102+00:00[UTC]"); -assert.sameValue(`${ zdt.toInstant() }`, "-001000-10-29T10:46:38.271986102Z"); - -// year 0 leap day -var zdt = Temporal.ZonedDateTime.from("0000-02-29T00:00-00:01[-00:01]"); -assert.sameValue(`${ zdt.toInstant() }`, "0000-02-29T00:01:00Z"); -zdt = Temporal.ZonedDateTime.from("+000000-02-29T00:00-00:01[-00:01]"); -assert.sameValue(`${ zdt.toInstant() }`, "0000-02-29T00:01:00Z"); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js deleted file mode 100644 index b6283e897d..0000000000 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Temporal.ZonedDateTime.prototype.toPlainDate() -features: [Temporal] ----*/ - -// works -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00"); -assert.sameValue(`${ zdt.toPlainDate() }`, "2019-10-29"); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js b/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js deleted file mode 100644 index e932b1413c..0000000000 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Temporal.ZonedDateTime.prototype.toPlainTime() -features: [Temporal] ----*/ - -// works -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00"); -assert.sameValue(`${ zdt.toPlainTime() }`, "02:46:38.271986102"); diff --git a/test/staging/Temporal/ZonedDateTime/old/toString.js b/test/staging/Temporal/ZonedDateTime/old/toString.js deleted file mode 100644 index 80637072a9..0000000000 --- a/test/staging/Temporal/ZonedDateTime/old/toString.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Temporal.ZonedDateTime.prototype.toString() -features: [Temporal] ----*/ - -var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]"); - -// shows offset if offset = auto -assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); - -// omits offset if offset = never -assert.sameValue(zdt1.toString({ offset: "never" }), "1976-11-18T15:23:00[UTC]");