From 09c7d33253a1174ec51d3b5c939dca5111a276f7 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 3 Oct 2024 11:27:57 -0700 Subject: [PATCH] Temporal: Add coverage for disallowed seconds in offset time zone identifiers This was an area missing test coverage. --- .../compare/relativeto-sub-minute-offset.js | 3 +++ .../round/relativeto-sub-minute-offset.js | 3 +++ .../total/relativeto-sub-minute-offset.js | 3 +++ .../timezone-string-sub-minute-offset.js | 20 +++++++++++++++ .../timezone-string-sub-minute-offset.js | 20 +++++++++++++++ .../timezone-string-sub-minute-offset.js | 18 +++++++++++++ .../timezone-string-sub-minute-offset.js | 18 +++++++++++++ .../timezone-string-sub-minute-offset.js | 18 +++++++++++++ .../timezone-string-sub-minute-offset.js | 18 +++++++++++++ .../timezone-string-sub-minute-offset.js | 20 +++++++++++++++ ...tybag-timezone-string-sub-minute-offset.js | 25 +++++++++++++++++++ .../argument-string-sub-minute-offset.js | 24 ++++++++++++++++++ ...tybag-timezone-string-sub-minute-offset.js | 18 +++++++++++++ .../from/argument-string-sub-minute-offset.js | 12 +++++++++ ...tybag-timezone-string-sub-minute-offset.js | 20 +++++++++++++++ .../argument-string-sub-minute-offset.js | 13 ++++++++++ ...tybag-timezone-string-sub-minute-offset.js | 20 +++++++++++++++ .../argument-string-sub-minute-offset.js | 13 ++++++++++ ...tybag-timezone-string-sub-minute-offset.js | 20 +++++++++++++++ .../argument-string-sub-minute-offset.js | 13 ++++++++++ .../timezone-string-sub-minute-offset.js | 20 +++++++++++++++ 21 files changed, 339 insertions(+) create mode 100644 test/built-ins/Temporal/Instant/prototype/toString/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Now/plainDateISO/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Now/plainTimeISO/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-sub-minute-offset.js diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-sub-minute-offset.js b/test/built-ins/Temporal/Duration/compare/relativeto-sub-minute-offset.js index 303efc9e45..63da8dfe18 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-sub-minute-offset.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-sub-minute-offset.js @@ -25,3 +25,6 @@ assert.sameValue(result, 0, "ISO string offset accepted with zero seconds (prope relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]"; assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone"); + +relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]"; +assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js index 48dcd4d397..cc7cadd620 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js @@ -25,3 +25,6 @@ TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "ISO string offset accept relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]"; assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone"); + +relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]"; +assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js index ff37d2a7f6..8cd44e2d0c 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js @@ -24,3 +24,6 @@ assert.sameValue(result, 366, "ISO string offset accepted with zero seconds (pro relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]"; assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone"); + +relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]"; +assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier"); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..907da1bb76 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.instant.prototype.tostring +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.toString({ timeZone }), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..5d3b8f6d7c --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.instant.prototype.tozoneddatetimeiso +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.toZonedDateTimeISO(timeZone), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..2de6cf170a --- /dev/null +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-sub-minute-offset.js @@ -0,0 +1,18 @@ +// 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.now.plaindateiso +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => Temporal.Now.plainDateISO(timeZone), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..b35f98252a --- /dev/null +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-sub-minute-offset.js @@ -0,0 +1,18 @@ +// 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.now.plaindatetimeiso +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => Temporal.Now.plainDateTimeISO(timeZone), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..caf51a99a7 --- /dev/null +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-sub-minute-offset.js @@ -0,0 +1,18 @@ +// 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.now.plaintimeiso +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => Temporal.Now.plainTimeISO(timeZone), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..eb0af2c46c --- /dev/null +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-sub-minute-offset.js @@ -0,0 +1,18 @@ +// 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.now.zoneddatetimeiso +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTimeISO(timeZone), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..f8c12ab7f0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.plaindate.prototype.tozoneddatetime +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(1970, 1, 1); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.toZonedDateTime(timeZone), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..1e6d7361c9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-sub-minute-offset.js @@ -0,0 +1,25 @@ +// 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.compare +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1588371240_000_000_000n, "+01:46"); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, instance), + `${timeZone} is not a valid time zone string (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(instance, { year: 2020, month: 5, day: 2, timeZone }), + `${timeZone} is not a valid time zone string (second argument)` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-sub-minute-offset.js new file mode 100644 index 0000000000..0485e66548 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-sub-minute-offset.js @@ -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.compare +description: > + ISO strings cannot have sub-minute UTC offset as a time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1588371240_000_000_000n, "+01:46"); + +const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"; + +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(str, instance), + `${str} is not a valid ISO string (first argument)` +); +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(instance, str), + `${str} is not a valid ISO string (second argument)` +); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..6a42ee4cc0 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-sub-minute-offset.js @@ -0,0 +1,18 @@ +// 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.from +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ year: 2020, month: 5, day: 2, timeZone }), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-sub-minute-offset.js new file mode 100644 index 0000000000..60143c3b3e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-sub-minute-offset.js @@ -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.from +description: > + ISO strings cannot have sub-minute UTC offset as a time zone identifier +features: [Temporal] +---*/ + +const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"; +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(str), `${str} is not a valid ISO string`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..549e51e782 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.equals +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.equals({ year: 2020, month: 5, day: 2, timeZone }), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-sub-minute-offset.js new file mode 100644 index 0000000000..dc43adf813 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-sub-minute-offset.js @@ -0,0 +1,13 @@ +// 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.equals +description: > + ISO strings cannot have sub-minute UTC offset as a time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); +const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"; +assert.throws(RangeError, () => instance.equals(str), `${str} is not a valid ISO string`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..407ed92989 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.since +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.since({ year: 2020, month: 5, day: 2, timeZone }), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-sub-minute-offset.js new file mode 100644 index 0000000000..ea649ac319 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-sub-minute-offset.js @@ -0,0 +1,13 @@ +// 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.since +description: > + ISO strings cannot have sub-minute UTC offset as a time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); +const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"; +assert.throws(RangeError, () => instance.since(str), `${str} is not a valid ISO string`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..b118699f2d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.until +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.until({ year: 2020, month: 5, day: 2, timeZone }), + `${timeZone} is not a valid time zone string` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-sub-minute-offset.js new file mode 100644 index 0000000000..d82d9e0010 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-sub-minute-offset.js @@ -0,0 +1,13 @@ +// 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.until +description: > + ISO strings cannot have sub-minute UTC offset as a time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); +const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"; +assert.throws(RangeError, () => instance.until(str), `${str} is not a valid ISO string`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-sub-minute-offset.js new file mode 100644 index 0000000000..1733493c35 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-sub-minute-offset.js @@ -0,0 +1,20 @@ +// 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.withtimezone +description: > + Time zone parsing from ISO strings does not accept sub-minute UTC offset as + time zone identifier +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) { + assert.throws( + RangeError, + () => instance.withTimeZone(timeZone), + `${timeZone} is not a valid time zone string` + ); +}