From 2e4e0e6b8ebe3348a207144204cb6d7a5571c863 Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Thu, 10 Aug 2023 00:20:37 -0700 Subject: [PATCH] Test ISO sub-minute offsets, incl. trailing zeroes Plugs a test hole where we were not fully testing ISO strings with sub-minute offsets, in particular those with trailing zeroes. --- ...to-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- ...to-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- ...to-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- ...to-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- ...to-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- .../toString/timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../Now/plainDate/timezone-string-datetime.js | 30 ++++++++++++++-- .../plainDateISO/timezone-string-datetime.js | 30 ++++++++++++++-- .../plainDateTime/timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../plainTimeISO/timezone-string-datetime.js | 30 ++++++++++++++-- .../zonedDateTime/timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- .../TimeZone/from/timezone-string-datetime.js | 30 ++++++++++++++-- .../equals/timezone-string-datetime.js | 30 ++++++++++++++-- ...nt-propertybag-timezone-string-datetime.js | 36 +++++++++++++++++-- ...nt-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- ...nt-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- ...nt-propertybag-timezone-string-datetime.js | 30 ++++++++++++++-- .../withTimeZone/timezone-string-datetime.js | 30 ++++++++++++++-- .../ZonedDateTime/timezone-string-datetime.js | 30 ++++++++++++++-- .../timezone-string-datetime.js | 30 ++++++++++++++-- 27 files changed, 761 insertions(+), 55 deletions(-) diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js index 0266336f2b..ff180122b4 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-timezone-string-datetime.js index 8967f111e0..968c3f7a71 100644 --- a/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Duration(1); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js index a432febdf1..2507e1ac71 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Duration(1); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-timezone-string-datetime.js index 6eacab939e..7a78717a79 100644 --- a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Duration(1); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js index 97ce80f642..a02c1498ce 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Duration(1); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js index 2a8172a3e3..ebfdaeeb91 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Instant(0n); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.toString({ timeZone }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.toString({ timeZone }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toString({ timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.toString({ timeZone }); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js index 3737ba16f1..fe543a8ead 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Instant(0n); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js index cace9df1e6..a8b7789e0b 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.Instant(0n); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.toZonedDateTimeISO(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.toZonedDateTimeISO(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTimeISO(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.toZonedDateTimeISO(timeZone); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js index d0233b8572..5c85577c0c 100644 --- a/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDate("iso8601", timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js index 332e59aa2a..575cddb8e5 100644 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateISO(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js index efa0f907ad..678fb2f789 100644 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateTime("iso8601", timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js index 8cacd0a189..4f39442ef3 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateTimeISO(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js index 6a9790c58b..4c5f22ffbc 100644 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainTimeISO(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js index c313a62b7a..4ec6f94f17 100644 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTime("iso8601", timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = Temporal.Now.zonedDateTime("iso8601", timeZone); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js index f3074339e1..4833b11bbd 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.zonedDateTimeISO(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.zonedDateTimeISO(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTimeISO(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = Temporal.Now.zonedDateTimeISO(timeZone); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js index d809691877..69be4a11ac 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.PlainDate(2000, 5, 2); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.toZonedDateTime(timeZone); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js index 2ed43505f2..07e48045a3 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.PlainDateTime(2000, 5, 2); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.toZonedDateTime(timeZone); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js index cde37b6834..8eb3307c67 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.PlainTime(); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js index 7d3cb9523e..30018a0d22 100644 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js +++ b/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.TimeZone.from(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.TimeZone.from(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.TimeZone.from(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = Temporal.TimeZone.from(timeZone); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js b/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js index 3768834301..ebbe31b3b7 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js +++ b/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js @@ -11,8 +11,34 @@ let tzUTC = Temporal.TimeZone.from("UTC"); let arg = "2021-08-19T17:30"; assert.throws(RangeError, () => tzUTC.equals(arg), "bare date-time string is not a time zone"); -arg = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => tzUTC.equals(arg), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => tzUTC.equals(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); arg = "2021-08-19T17:30Z"; tzUTC = Temporal.TimeZone.from(arg); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js index e6356e5146..49a0f0eaa3 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js @@ -13,9 +13,39 @@ let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, timeZone }, instance), "bare date-time string is not a time zone (arg 1)"); assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(instance, { year: 2000, month: 5, day: 2, timeZone }), "bare date-time string is not a time zone (arg 2)"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, timeZone }, instance), "ISO string sub-minute offset is not OK as time zone (arg 1)"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(instance, { year: 2000, month: 5, day: 2, timeZone }), "ISO string sub-minute offset is not OK as time zone (arg 2)"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, timeZone }, instance), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone (arg 1)` + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(instance, { year: 2000, month: 5, day: 2, timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone (arg 2)` + ); +}); // The following are all valid strings so should not throw: diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js index b7a531bd21..c70faa2430 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-datetime.js index d08bbf58fb..02315b7c6b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-datetime.js @@ -13,8 +13,34 @@ const instance1 = new Temporal.ZonedDateTime(0n, expectedTimeZone); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance1.since({ year: 2020, month: 5, day: 2, timeZone }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance1.since({ year: 2020, month: 5, day: 2, timeZone }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance1.since({ year: 2020, month: 5, day: 2, timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw. They should produce // expectedTimeZone, so additionally the operation will not throw due to the diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js index 6f4929da19..3373b02be4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js @@ -13,8 +13,34 @@ const instance1 = new Temporal.ZonedDateTime(0n, expectedTimeZone); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance1.until({ year: 2020, month: 5, day: 2, timeZone }), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance1.until({ year: 2020, month: 5, day: 2, timeZone }), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance1.until({ year: 2020, month: 5, day: 2, timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw. They should produce // expectedTimeZone, so additionally the operation will not throw due to the diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js index 3378f89bcf..c5b06f34d8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js @@ -12,8 +12,34 @@ const instance = new Temporal.ZonedDateTime(0n, "UTC"); let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => instance.withTimeZone(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => instance.withTimeZone(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.withTimeZone(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = instance.withTimeZone(timeZone); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js index 243d6dc380..3c89de29a8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js @@ -10,8 +10,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => new Temporal.ZonedDateTime(0n, timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => new Temporal.ZonedDateTime(0n, timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => new Temporal.ZonedDateTime(0n, timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); timeZone = "2021-08-19T17:30Z"; const result1 = new Temporal.ZonedDateTime(0n, timeZone); diff --git a/test/intl402/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js b/test/intl402/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js index fe2dd69e42..cde0b12b25 100644 --- a/test/intl402/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js +++ b/test/intl402/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js @@ -9,8 +9,34 @@ features: [Temporal] let timeZone = "2021-08-19T17:30"; assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), "bare date-time string is not a time zone"); -timeZone = "2021-08-19T17:30-07:00:01"; -assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), "ISO string sub-minute offset is not OK as time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateTimeISO(timeZone), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); // The following are all valid strings so should not throw: