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 e4799db5e02..303efc9e452 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 @@ -3,19 +3,25 @@ /*--- esid: sec-temporal.duration.compare -description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +description: relativeTo string accepts trailing zeroes in sub-minute UTC offset features: [Temporal] ---*/ const duration1 = new Temporal.Duration(0, 0, 0, 31); const duration2 = new Temporal.Duration(0, 1); -let relativeTo = "2000-01-01T00:00+00:45[+00:44:30.123456789]"; -assert.sameValue(Temporal.Duration.compare(duration1, duration2, { relativeTo }), 0, "rounded HH:MM is accepted in string"); +let result; +let relativeTo; -relativeTo = "2000-01-01T00:00+00:44:30[+00:44:30.123456789]"; -assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo }), "no other rounding is accepted for offset"); +const action = (relativeTo) => Temporal.Duration.compare(duration1, duration2, { relativeTo }); -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -relativeTo = { year: 2000, month: 1, day: 1, offset: "+00:45", timeZone }; -assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo }), "rounded HH:MM not accepted as offset in property bag"); +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +assert.sameValue(result, 0, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +assert.sameValue(result, 0, "ISO string offset accepted with zero seconds (property bag)"); + +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"); diff --git a/test/built-ins/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.js b/test/built-ins/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.js index 294b5974fb3..b80d60831a3 100644 --- a/test/built-ins/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.js +++ b/test/built-ins/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.js @@ -3,20 +3,23 @@ /*--- esid: sec-temporal.duration.prototype.add -description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +description: relativeTo string accepts trailing zeroes in sub-minute UTC offset includes: [temporalHelpers.js] features: [Temporal] ---*/ const instance = new Temporal.Duration(1, 0, 0, 1); +let result; +let relativeTo; +const action = (relativeTo) => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -let relativeTo = "2000-01-01T00:00+00:45[+00:44:30.123456789]"; -const result = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "rounded HH:MM is accepted in string"); +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (string)"); -relativeTo = "2000-01-01T00:00+00:44:30[+00:44:30.123456789]"; -assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), "no other rounding is accepted for offset"); +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (property bag)"); -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -relativeTo = { year: 2000, month: 1, day: 1, offset: "+00:45", timeZone }; -assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), "rounded HH:MM not accepted as offset in property bag"); +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"); 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 83910ac5e9f..48dcd4d3974 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 @@ -3,20 +3,25 @@ /*--- esid: sec-temporal.duration.prototype.round -description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +description: relativeTo string accepts trailing zeroes in sub-minute UTC offset includes: [temporalHelpers.js] features: [Temporal] ---*/ const instance = new Temporal.Duration(1, 0, 0, 0, 24); -let relativeTo = "2000-01-01T00:00+00:45[+00:44:30.123456789]"; -const result = instance.round({ largestUnit: "years", relativeTo }); -TemporalHelpers.assertDuration(result, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "rounded HH:MM is accepted in string"); +let result; +let relativeTo; -relativeTo = "2000-01-01T00:00+00:44:30[+00:44:30.123456789]"; -assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "no other rounding is accepted for offset"); +const action = (relativeTo) => instance.round({ largestUnit: "years", relativeTo }); -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -relativeTo = { year: 2000, month: 1, day: 1, offset: "+00:45", timeZone }; -assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "rounded HH:MM not accepted as offset in property bag"); +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "ISO string offset accepted with zero seconds (property bag)"); + +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"); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js index 8c7292aef98..a84801e02c7 100644 --- a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js +++ b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js @@ -3,20 +3,24 @@ /*--- esid: sec-temporal.duration.prototype.subtract -description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +description: relativeTo string accepts trailing zeroes in sub-minute UTC offset includes: [temporalHelpers.js] features: [Temporal] ---*/ const instance = new Temporal.Duration(1, 0, 0, 1); -let relativeTo = "2000-01-01T00:00+00:45[+00:44:30.123456789]"; -const result = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "rounded HH:MM is accepted in string"); +let result; +let relativeTo; +const action = (relativeTo) => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -relativeTo = "2000-01-01T00:00+00:44:30[+00:44:30.123456789]"; -assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), "no other rounding is accepted for offset"); +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (string)"); -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -relativeTo = { year: 2000, month: 1, day: 1, offset: "+00:45", timeZone }; -assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), "rounded HH:MM not accepted as offset in property bag"); +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (property bag)"); + +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"); 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 eab08d75475..ff37d2a7f60 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 @@ -3,19 +3,24 @@ /*--- esid: sec-temporal.duration.prototype.total -description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +description: relativeTo string accepts trailing zeroes in sub-minute UTC offset features: [Temporal] ---*/ const instance = new Temporal.Duration(1, 0, 0, 0, 24); -let relativeTo = "2000-01-01T00:00+00:45[+00:44:30.123456789]"; -const result = instance.total({ unit: "days", relativeTo }); -assert.sameValue(result, 367, "rounded HH:MM is accepted in string"); +let result; +let relativeTo; -relativeTo = "2000-01-01T00:00+00:44:30[+00:44:30.123456789]"; -assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "no other rounding is accepted for offset"); +const action = (relativeTo) => instance.total({ unit: "days", relativeTo }); -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -relativeTo = { year: 2000, month: 1, day: 1, offset: "+00:45", timeZone }; -assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "rounded HH:MM not accepted as offset in property bag"); +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +assert.sameValue(result, 366, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +assert.sameValue(result, 366, "ISO string offset accepted with zero seconds (property bag)"); + +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"); diff --git a/test/built-ins/Temporal/Instant/compare/instant-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/compare/instant-string-multiple-offsets.js index 1417e3dc942..f29d9dead82 100644 --- a/test/built-ins/Temporal/Instant/compare/instant-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/compare/instant-string-multiple-offsets.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const epoch = new Temporal.Instant(0n); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; assert.sameValue(Temporal.Instant.compare(str, epoch), 0, "UTC offset determined from offset part of string (first argument)"); assert.sameValue(Temporal.Instant.compare(epoch, str), 0, "UTC offset determined from offset part of string (second argument)"); diff --git a/test/built-ins/Temporal/Instant/from/instant-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/from/instant-string-multiple-offsets.js index b8f6178d054..f2e6fc312fb 100644 --- a/test/built-ins/Temporal/Instant/from/instant-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/from/instant-string-multiple-offsets.js @@ -7,7 +7,7 @@ description: Instant strings with UTC offset fractional part are not confused wi features: [Temporal] ---*/ -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; const result = Temporal.Instant.from(str); assert.sameValue(result.epochNanoseconds, 0n, "UTC offset determined from offset part of string"); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js index 7f8d1bcc07a..1780936cda0 100644 --- a/test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; const result = instance.equals(str); assert.sameValue(result, true, "UTC offset determined from offset part of string"); diff --git a/test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js index 6bf08bef5e9..f22ae7c9fe6 100644 --- a/test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js @@ -9,7 +9,7 @@ features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; const result = instance.since(str); TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "UTC offset determined from offset part of string"); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js index 2bcdaced03b..1914167cf06 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js @@ -17,5 +17,3 @@ function test(timeZoneIdentifier, expected, description) { test("UTC", "1970-01-01T00:00:00+00:00", "offset of UTC is +00:00"); test("+01:00", "1970-01-01T01:00:00+01:00", "positive offset"); test("-05:00", "1969-12-31T19:00:00-05:00", "negative offset"); -test("+00:44:59.123456789", "1970-01-01T00:44:59.123456789+00:45", "sub-minute offset"); -test("-00:00:10.987654321", "1969-12-31T23:59:49.012345679+00:00", "sub-minute offset that rounds to zero"); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js index 2b16120473f..db32279e399 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.instant.prototype.tostring -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone strings with UTC offset are not confused with time features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.toString({ timeZone }); -assert.sameValue(result.substr(-6), "+01:46", "Time zone string determined from offset"); +assert.sameValue(result.substr(-6), "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js index ec9250d56c4..41da34eccc7 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.instant.prototype.tozoneddatetime -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js index 3fbfc4a12b6..9c3003d2ee9 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.instant.prototype.tozoneddatetimeiso -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.toZonedDateTimeISO(timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js index 5b6300473ea..c76083c6843 100644 --- a/test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js @@ -9,7 +9,7 @@ features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; const result = instance.until(str); TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "UTC offset determined from offset part of string"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js index a3e26f66a97..feb44683c7c 100644 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js @@ -3,11 +3,11 @@ /*--- esid: sec-temporal.now.zoneddatetime -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets.js index 1ecfceaff38..a4a0c963b42 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets.js @@ -3,11 +3,11 @@ /*--- esid: sec-temporal.now.zoneddatetimeiso -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = Temporal.Now.zonedDateTimeISO(timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js index fa98f2c05df..2de2f0c8cb6 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const date = new Temporal.PlainDate(2000, 5, 2); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js index 2b97bd1b5aa..44484630d1c 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js @@ -28,13 +28,14 @@ info: | ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.plaindate.prototype.tozoneddatetime step 6.a: a. Set _temporalTime_ to ? ToTemporalTime(_temporalTime_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const otherTimeZone = new Temporal.TimeZone("UTC"); // should not be used to convert datetime to PlainTime diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js index bc570508663..1aa7eafc9ef 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ const instance = new Temporal.PlainDate(2000, 5, 2); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.toZonedDateTime(timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js index 92492b7f2f5..83b4f71311a 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const pdt = Temporal.PlainDateTime.from(datetime); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js index da4d9c59c6a..f09be96fc07 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js @@ -28,13 +28,14 @@ info: | ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.plaindatetime.prototype.until step 3: 3. Set _other_ ? ToTemporalDateTime(_other_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); assert(new Temporal.PlainDateTime(1970, 1, 1, 1, 1, 1, 1, 0, 999).equals(datetime)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js index cd633b338d1..963e5170415 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const diff = new Temporal.PlainDateTime(1970, 1, 1).since(datetime); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js index 7c8c9a08192..ec22dd5a83b 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ const instance = new Temporal.PlainDateTime(2000, 5, 2); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.toZonedDateTime(timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js index 3353d9960a4..54102c1ab88 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const diff = new Temporal.PlainDateTime(1970, 1, 1).until(datetime); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js index dec1fcd8c9c..ca5ae0e47a4 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const pdt = new Temporal.PlainDateTime(2000, 5, 2); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js index 6013cb32b71..a57ecf3740b 100644 --- a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const time = Temporal.PlainTime.from(datetime); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js index 75db40bce71..af190427a88 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js @@ -28,13 +28,14 @@ info: | ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.plaintime.prototype.equals step 3: 3. Set _other_ to ? ToTemporalTime(_other_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); assert(new Temporal.PlainTime(1, 1, 1, 1, 0, 999).equals(datetime)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js index e1ab14b1500..af08e3d8fc4 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const diff = new Temporal.PlainTime().since(datetime); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js index e70db04f473..8c8e37a488f 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.plaintime.prototype.tozoneddatetime -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ const instance = new Temporal.PlainTime(); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js index 35c808f2832..e6c212cb414 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js @@ -35,7 +35,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const diff = new Temporal.PlainTime().until(datetime); diff --git a/test/built-ins/Temporal/TimeZone/basic.js b/test/built-ins/Temporal/TimeZone/basic.js index a803f729b80..5b12b574667 100644 --- a/test/built-ins/Temporal/TimeZone/basic.js +++ b/test/built-ins/Temporal/TimeZone/basic.js @@ -16,10 +16,6 @@ const valid = [ ["\u221201:00", "-01:00"], ["\u22120650", "-06:50"], ["\u221208", "-08:00"], - ["+01:00:00", "+01:00"], - ["-010000", "-01:00"], - ["+03:30:00.000000001", "+03:30:00.000000001"], - ["-033000.1", "-03:30:00.1"], ["UTC"], ]; for (const [zone, id = zone] of valid) { @@ -28,7 +24,7 @@ for (const [zone, id = zone] of valid) { assert.sameValue(result.id, id, `id for ${zone} should be ${id}`); } -const invalid = ["+00:01.1", "-01.1"]; +const invalid = ["+00:01.1", "-01.1", "+01:00:00", "-010000", "+03:30:00.000000001", "-033000.1"]; for (const zone of invalid) { assert.throws(RangeError, () => new Temporal.TimeZone(zone), `should throw for ${zone}`); } diff --git a/test/built-ins/Temporal/TimeZone/from/argument-primitive.js b/test/built-ins/Temporal/TimeZone/from/argument-primitive.js index a915eb635f4..f10ffb80a3a 100644 --- a/test/built-ins/Temporal/TimeZone/from/argument-primitive.js +++ b/test/built-ins/Temporal/TimeZone/from/argument-primitive.js @@ -21,6 +21,10 @@ const primitives = [ "-01.1", "1994-11-05T08:15:30+25:00", "1994-11-05T13:15:30-25:00", + "+01:00:00", + "-010000", + "+03:30:00.000000001", + "-033000.1", 7, 4.2, 12n, diff --git a/test/built-ins/Temporal/TimeZone/from/argument-valid.js b/test/built-ins/Temporal/TimeZone/from/argument-valid.js index 21c74a77f57..4ca5998d2a2 100644 --- a/test/built-ins/Temporal/TimeZone/from/argument-valid.js +++ b/test/built-ins/Temporal/TimeZone/from/argument-valid.js @@ -16,10 +16,6 @@ const valids = [ ["\u221201:00", "-01:00"], ["\u22120650", "-06:50"], ["\u221208", "-08:00"], - ["+01:00:00", "+01:00"], - ["-010000", "-01:00"], - ["+03:30:00.000000001", "+03:30:00.000000001"], - ["-033000.1", "-03:30:00.1"], ["UTC"], ["1994-11-05T08:15:30-05:00", "-05:00"], ["1994-11-05T08:15:30\u221205:00", "-05:00"], diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js index e8b686fe038..e37fbab887b 100644 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js @@ -3,11 +3,11 @@ /*--- esid: sec-temporal.timezone.from -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = Temporal.TimeZone.from(timeZone); -assert.sameValue(result.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.id, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js index 61a009f4d93..451e8cb7b55 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js @@ -28,13 +28,14 @@ info: | ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.timezone.prototype.getinstantfor step 3: 3. Set _dateTime_ ? ToTemporalDateTime(_dateTime_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const conversionTimeZone = new Temporal.TimeZone("UTC"); // should not be used to interpret the argument diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js index e0f58f0ab37..184bb12a20b 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js @@ -17,4 +17,3 @@ function test(timeZoneIdentifier, expectedOffsetString, description) { test("UTC", "+00:00", "offset of UTC is +00:00"); test("+01:00", "+01:00", "positive offset"); test("-05:00", "-05:00", "negative offset"); -test("+00:44:59.123456789", "+00:44:59.123456789", "sub-minute offset is not rounded"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js index 02af26a36ba..80eb51d64ff 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js @@ -31,7 +31,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const instant = new Temporal.Instant(1001n); const pdt = tz.getPlainDateTimeFor(instant); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js index a0a525a447b..e7abec396e1 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js @@ -9,7 +9,7 @@ features: [Temporal] ---*/ const instance = new Temporal.TimeZone("UTC"); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; const result = instance.getPlainDateTimeFor(str); TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "UTC offset determined from offset part of string"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js index 7b5b97cf529..45147806825 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js @@ -28,13 +28,14 @@ info: | ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.timezone.prototype.getpossibleinstantsfor step 3: 3. Set _dateTime_ ? ToTemporalDateTime(_dateTime_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const conversionTimeZone = new Temporal.TimeZone("UTC"); // should not be used to interpret the argument diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js index 1902b882780..1ee2b28fc61 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js @@ -16,11 +16,23 @@ includes: [temporalHelpers.js] Symbol(), 3600_000_000_000n, {}, - { valueOf() { return 3600_000_000_000; } }, + { + valueOf() { + return 3600_000_000_000; + } + } ].forEach((wrongOffset) => { const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, hour: 12, timeZone }, datetime)); - assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(datetime, { year: 2000, month: 5, day: 2, hour: 12, timeZone })); + assert.throws( + TypeError, + () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, hour: 12, timeZone }, datetime), + `invalid offset: ${String(wrongOffset)} (${typeof wrongOffset})` + ); + assert.throws( + TypeError, + () => Temporal.ZonedDateTime.compare(datetime, { year: 2000, month: 5, day: 2, hour: 12, timeZone }), + `invalid offset: ${String(wrongOffset)} (${typeof wrongOffset})` + ); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-multiple-offsets.js index 2e47557fa1a..97e623f5358 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-multiple-offsets.js @@ -3,13 +3,13 @@ /*--- esid: sec-temporal.zoneddatetime.compare -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1588371269_012_345_679n, "+01:45:30.987654321"); +const instance = new Temporal.ZonedDateTime(1588371240_000_000_000n, "+01:46"); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result1 = Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, instance); assert.sameValue(result1, 0, "Time zone string determined from bracket name (first argument)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js index 25a27a21f26..27c367fbcdc 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js @@ -3,12 +3,32 @@ /*--- esid: sec-temporal.zoneddatetime.compare -description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +description: Sub-minute offset trailing zeroes allowed in ISO string but not in bracketed offset features: [Temporal] ---*/ -const datetime = new Temporal.ZonedDateTime(29_012_345_679n, "+00:01:30.987654321"); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +const datetime = new Temporal.ZonedDateTime(30_000_000_000n, "+01:35"); +let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; -assert.sameValue(Temporal.ZonedDateTime.compare(str, datetime), 0, "Time zone determined from bracket name (first argument)"); -assert.sameValue(Temporal.ZonedDateTime.compare(datetime, str), 0, "Time zone determined from bracket name (second argument)"); +assert.sameValue( + Temporal.ZonedDateTime.compare(str, datetime), + 0, + "Time zone determined from bracket name (first argument)" +); +assert.sameValue( + Temporal.ZonedDateTime.compare(datetime, str), + 0, + "Time zone determined from bracket name (second argument)" +); + +str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]"; +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(str, datetime), + "Trailing zeroes not allowed for sub-minute time zone identifiers (first argument)" +); +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, str), + "Trailing zeroes not allowed for sub-minute time zone identifiers (second argument)" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js index 5d611a1e550..745e9c4d1ea 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js @@ -16,9 +16,17 @@ includes: [temporalHelpers.js] Symbol(), 3600_000_000_000n, {}, - { valueOf() { return 3600_000_000_000; } }, + { + valueOf() { + return 3600_000_000_000; + } + } ].forEach((wrongOffset) => { const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - assert.throws(TypeError, () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, timeZone })); + assert.throws( + TypeError, + () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, timeZone }), + `invalid offset: ${String(wrongOffset)} (${typeof wrongOffset})` + ); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-multiple-offsets.js index 0ed9870136a..1f65c98b5c6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-multiple-offsets.js @@ -3,11 +3,11 @@ /*--- esid: sec-temporal.zoneddatetime.from -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string-multiple-offsets.js index 5ceb088ed2d..c2f53b2a3ed 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string-multiple-offsets.js @@ -3,11 +3,18 @@ /*--- esid: sec-temporal.zoneddatetime.from -description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +description: Sub-minute offset trailing zeroes allowed in ISO string but not in bracketed offset features: [Temporal] ---*/ -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; const result = Temporal.ZonedDateTime.from(str); -assert.sameValue(result.timeZoneId, "+00:01:30.987654321", "Time zone determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:35", "Time zone determined from bracket name"); + +str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]"; +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(str), + "Trailing zeroes not allowed for sub-minute time zone identifiers" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset.js deleted file mode 100644 index f35d1451398..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset.js +++ /dev/null @@ -1,43 +0,0 @@ -// 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.from -description: Fuzzy matching behaviour with UTC offsets in ISO 8601 strings and offset option -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -["use", "ignore", "prefer", "reject"].forEach((offset) => { - const result = Temporal.ZonedDateTime.from("1970-01-01T12:00-00:44:30.123456789[-00:44:30.123456789]", { offset }); - assert.sameValue(result.epochNanoseconds, 45870_123_456_789n, `accepts the exact offset string (offset=${offset})`); - assert.sameValue(result.offset, "-00:44:30.123456789", "offset property is correct"); -}); - -assert.throws(RangeError, () => Temporal.ZonedDateTime.from("1970-01-01T00:00-00:44:30[-00:44:30.123456789]", { offset: "reject" }), "offset=reject does not accept any other rounding than minutes"); - -const str = "1970-01-01T12:00-00:45[-00:44:30.123456789]"; - -["ignore", "prefer", "reject"].forEach((offset) => { - const result = Temporal.ZonedDateTime.from(str, { offset }); - assert.sameValue(result.epochNanoseconds, 45870_123_456_789n, `accepts the offset string rounded to minutes (offset=${offset})`); - assert.sameValue(result.offset, "-00:44:30.123456789", "offset property is still the full precision"); - TemporalHelpers.assertPlainDateTime(result.toPlainDateTime(), 1970, 1, "M01", 1, 12, 0, 0, 0, 0, 0, "wall time is preserved"); -}); - -const result = Temporal.ZonedDateTime.from(str, { offset: "use" }); -assert.sameValue(result.epochNanoseconds, 45900_000_000_000n, "prioritizes the offset string with HH:MM precision when offset=use"); -assert.sameValue(result.offset, "-00:44:30.123456789", "offset property is still the full precision"); -TemporalHelpers.assertPlainDateTime(result.toPlainDateTime(), 1970, 1, "M01", 1, 12, 0, 29, 876, 543, 211, "wall time is shifted by the difference between exact and rounded offset"); - -const properties = { year: 1970, month: 1, day: 1, hour: 12, offset: "-00:45", timeZone: "-00:44:30.123456789" }; - -["ignore", "prefer"].forEach((offset) => { - const result = Temporal.ZonedDateTime.from(properties, { offset }); - assert.sameValue(result.epochNanoseconds, 45870_123_456_789n, `no fuzzy matching is done on offset in property bag (offset=${offset})`); -}); - -const result2 = Temporal.ZonedDateTime.from(properties, { offset: "use" }); -assert.sameValue(result2.epochNanoseconds, 45900_000_000_000n, "no fuzzy matching is done on offset in property bag (offset=use)"); - -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(properties, { offset: "reject" }), "no fuzzy matching is done on offset in property bag (offset=reject)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js index a6670be9591..be9f273c935 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js @@ -24,13 +24,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.day step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(86400_000_000_001n, tz); assert.sameValue(datetime.day, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-multiple-offsets.js index ae1c3017ebf..530e31248a8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-multiple-offsets.js @@ -3,17 +3,17 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.equals -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const expectedTimeZone = "+01:45:30.987654321"; +const expectedTimeZone = "+01:46"; const instance = new Temporal.ZonedDateTime(0n, expectedTimeZone); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; // This operation should produce expectedTimeZone, so the following should // be equal due to the time zones being different on the receiver and // the argument. -const properties = { year: 1970, month: 1, day: 1, hour: 1, minute: 45, second: 30, millisecond: 987, microsecond: 654, nanosecond: 321 }; +const properties = { year: 1970, month: 1, day: 1, hour: 1, minute: 46 }; assert(instance.equals({ ...properties, timeZone }), "time zone string should produce expected time zone"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js deleted file mode 100644 index ddd43b1ae60..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js +++ /dev/null @@ -1,19 +0,0 @@ -// 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.equals -description: Fuzzy matching behaviour for UTC offset in ISO 8601 string -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -const result = instance.equals("1970-01-01T00:44:30.123456789+00:45[+00:44:30.123456789]"); -assert.sameValue(result, true, "UTC offset rounded to minutes is accepted"); - -assert.throws(RangeError, () => instance.equals("1970-01-01T00:44:30.123456789+00:44:30[+00:44:30.123456789]"), "no other rounding than minutes is accepted"); - -const properties = { offset: "+00:45", year: 1970, month: 1, day: 1, minute: 44, second: 30, millisecond: 123, microsecond: 456, nanosecond: 123, timeZone }; -assert.throws(RangeError, () => instance.equals(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js index ae485b19125..6af0737c750 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js @@ -3,13 +3,20 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.equals -description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +description: Sub-minute offset trailing zeroes allowed in ISO string but not in bracketed offset features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+00:01:30.987654321"); +const timeZone = new Temporal.TimeZone("+01:35"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; const result = instance.equals(str); assert.sameValue(result, false, "Time zone determined from bracket name"); + +str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]"; +assert.throws( + RangeError, + () => instance.equals(str), + "Trailing zeroes not allowed for sub-minute time zone identifiers" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js index e8557b7c917..3ebd5e70bb9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js @@ -24,13 +24,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.getisofields step 7: 7. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // ZonedDateTime -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1001n, tz); const fields = datetime.getISOFields(); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js index 1894f7989af..96fa20c61fc 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js @@ -17,4 +17,3 @@ function test(timeZoneIdentifier, expectedOffsetString, description) { test("UTC", "+00:00", "offset of UTC is +00:00"); test("+01:00", "+01:00", "positive offset"); test("-05:00", "-05:00", "negative offset"); -test("+00:44:59.123456789", "+00:44:59.123456789", "sub-minute offset is not rounded"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js index 3e229c0a32e..5343d7074ec 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js @@ -22,13 +22,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.hour step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3600_000_000_001n, tz); assert.sameValue(datetime.hour, 0); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js index f0e5cae171d..1e3dedd64a5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js @@ -14,13 +14,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.microsecond step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1001n, tz); assert.sameValue(datetime.microsecond, 0); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js index 7156d9ebdb1..dc42bfd3c05 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js @@ -16,13 +16,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.millisecond step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1_000_001n, tz); assert.sameValue(datetime.millisecond, 0); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js index 707ec034037..89e91160bc6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js @@ -22,13 +22,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.minute step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(60_000_000_001n, tz); assert.sameValue(datetime.minute, 0); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js index 89bae12c0d0..6c104323ed3 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js @@ -16,4 +16,3 @@ function test(timeZoneIdentifier, expectedOffsetString, description) { test("UTC", "+00:00", "offset of UTC is +00:00"); test("+01:00", "+01:00", "positive offset"); test("-05:00", "-05:00", "negative offset"); -test("+00:44:59.123456789", "+00:44:59.123456789", "sub-minute offset is not rounded"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js index 79e91712fd6..8422d20a5f2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js @@ -18,13 +18,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.second step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1_000_000_001n, tz); assert.sameValue(datetime.second, 0); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-multiple-offsets.js index c2a4fce8f12..0f919c221f4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-multiple-offsets.js @@ -3,13 +3,13 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.since -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const expectedTimeZone = "+01:45:30.987654321"; +const expectedTimeZone = "+01:46"; const instance = new Temporal.ZonedDateTime(0n, expectedTimeZone); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; // This operation should produce expectedTimeZone, so the following operation // should not throw due to the time zones being different on the receiver and diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js deleted file mode 100644 index a0d2522666e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js +++ /dev/null @@ -1,20 +0,0 @@ -// 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.since -description: Fuzzy matching behaviour for UTC offset in ISO 8601 string -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -const result = instance.since("1970-01-01T00:44:30.123456789+00:45[+00:44:30.123456789]"); -TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "UTC offset rounded to minutes is accepted"); - -assert.throws(RangeError, () => instance.since("1970-01-01T00:44:30.123456789+00:44:30[+00:44:30.123456789]"), "no other rounding than minutes is accepted"); - -const properties = { offset: "+00:45", year: 1970, month: 1, day: 1, minute: 44, second: 30, millisecond: 123, microsecond: 456, nanosecond: 123, timeZone }; -assert.throws(RangeError, () => instance.since(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js index f28b3d847e9..d973fd768c2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js @@ -3,14 +3,21 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.since -description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +description: Sub-minute offset trailing zeroes allowed in ISO string but not in bracketed offset includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+00:01:30.987654321"); +const timeZone = new Temporal.TimeZone("+01:35"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; const result = instance.since(str); -TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, -29, -12, -345, -679, "Time zone determined from bracket name"); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, -30, 0, 0, 0, "ISO offset, sub-minute offset trailing-zeroes"); + +str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]"; +assert.throws( + RangeError, + () => instance.since(str), + "Trailing zeroes not allowed for sub-minute time zone identifiers" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js index 81febbcc022..b396a8e4272 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js @@ -26,13 +26,14 @@ info: | 9. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _isoCalendar_). sec-get-temporal.zoneddatetime.prototype.tojson step 3: 3. Return ? TemporalZonedDateTimeToString(_zonedDateTime_, *"auto"*, *"auto"*, *"auto"*, *"auto"*). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // ZonedDateTime -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1001n, tz); const jsonString = datetime.toJSON(); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js index 7a3410501dd..e3246b9946d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js @@ -16,5 +16,3 @@ function test(timeZoneIdentifier, expected, description) { test("UTC", "1970-01-01T00:00:00+00:00[UTC]", "offset of UTC is +00:00"); test("+01:00", "1970-01-01T01:00:00+01:00[+01:00]", "positive offset"); test("-05:00", "1969-12-31T19:00:00-05:00[-05:00]", "negative offset"); -test("+00:44:59.123456789", "1970-01-01T00:44:59.123456789+00:45[+00:44:59.123456789]", "sub-minute offset"); -test("-00:00:10.987654321", "1969-12-31T23:59:49.012345679+00:00[-00:00:10.987654321]", "sub-minute offset that rounds to zero"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js index 788ae268bfc..e9dbd5088ec 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js @@ -31,7 +31,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1001n, tz); const pdt = datetime.toPlainDateTime(); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js index ade5862d6cf..c9b0107d314 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js @@ -31,7 +31,7 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1001n, tz); const time = datetime.toPlainTime(); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js index 0e3df5e7664..e3db9562d2d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js @@ -26,13 +26,14 @@ info: | 9. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _isoCalendar_). sec-get-temporal.zoneddatetime.prototype.tostring step 9: 9. Return ? TemporalZonedDateTimeToString(_zonedDateTime_, _precision_.[[Precision]], _showCalendar_, _showTimeZone_, _showOffset_, _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // ZonedDateTime -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(1001n, tz); const isoString = datetime.toString(); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js index c48025f99c9..5ff25b6c716 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js @@ -16,5 +16,3 @@ function test(timeZoneIdentifier, expected, description) { test("UTC", "1970-01-01T00:00:00+00:00[UTC]", "offset of UTC is +00:00"); test("+01:00", "1970-01-01T01:00:00+01:00[+01:00]", "positive offset"); test("-05:00", "1969-12-31T19:00:00-05:00[-05:00]", "negative offset"); -test("+00:44:59.123456789", "1970-01-01T00:44:59.123456789+00:45[+00:44:59.123456789]", "sub-minute offset"); -test("-00:00:10.987654321", "1969-12-31T23:59:49.012345679+00:00[-00:00:10.987654321]", "sub-minute offset that rounds to zero"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-multiple-offsets.js index c1d88c4c242..0bb986b8b5c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-multiple-offsets.js @@ -3,13 +3,13 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const expectedTimeZone = "+01:45:30.987654321"; +const expectedTimeZone = "+01:46"; const instance = new Temporal.ZonedDateTime(0n, expectedTimeZone); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; // This operation should produce expectedTimeZone, so the following operation // should not throw due to the time zones being different on the receiver and diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js deleted file mode 100644 index 8077e6707cb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js +++ /dev/null @@ -1,20 +0,0 @@ -// 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.until -description: Fuzzy matching behaviour for UTC offset in ISO 8601 string -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("+00:44:30.123456789"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -const result = instance.until("1970-01-01T00:44:30.123456789+00:45[+00:44:30.123456789]"); -TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "UTC offset rounded to minutes is accepted"); - -assert.throws(RangeError, () => instance.until("1970-01-01T00:44:30.123456789+00:44:30[+00:44:30.123456789]"), "no other rounding than minutes is accepted"); - -const properties = { offset: "+00:45", year: 1970, month: 1, day: 1, minute: 44, second: 30, millisecond: 123, microsecond: 456, nanosecond: 123, timeZone }; -assert.throws(RangeError, () => instance.until(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js index 230d40d1b1d..6330d8710b0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js @@ -3,14 +3,21 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until -description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +description: Sub-minute offset trailing zeroes allowed in ISO string but not in bracketed offset includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+00:01:30.987654321"); +const timeZone = new Temporal.TimeZone("+01:35"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; +let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; const result = instance.until(str); -TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 29, 12, 345, 679, "Time zone determined from bracket name"); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, "ISO offset, sub-minute offset trailing-zeroes"); + +str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35:00.000000000]"; +assert.throws( + RangeError, + () => instance.until(str), + "Trailing zeroes not allowed for sub-minute time zone identifiers" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js index ab2372b537e..8ece6fc6055 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js @@ -28,13 +28,14 @@ info: | ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.zoneddatetime.prototype.withplaintime step 4.a: a. Let _plainTime_ be ? ToTemporalTime(_plainTimeLike_). +includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = new Temporal.TimeZone("-00:00:00.000000002"); +const tz = TemporalHelpers.specificOffsetTimeZone(-2); const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); const otherTimeZone = new Temporal.TimeZone("UTC"); // should not be used to convert datetime -> PlainTime diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js index e36156c1aad..46f6b4c1ed5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.withtimezone -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ const instance = new Temporal.ZonedDateTime(0n, "UTC"); -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = instance.withTimeZone(timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js index a57aab67f2e..f744d75470b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js @@ -3,11 +3,11 @@ /*--- esid: sec-temporal.zoneddatetime -description: Time zone strings with UTC offset fractional part are not confused with time fractional part +description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset features: [Temporal] ---*/ -const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; +const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; const result = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result.timeZoneId, "+01:45:30.987654321", "Time zone string determined from bracket name"); +assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js new file mode 100644 index 00000000000..67e842da798 --- /dev/null +++ b/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js @@ -0,0 +1,28 @@ +// 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.duration.compare +description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +features: [Temporal] +---*/ + +const duration1 = new Temporal.Duration(0, 0, 0, 31); +const duration2 = new Temporal.Duration(0, 1); + +let result; +let relativeTo; + +const action = (relativeTo) => Temporal.Duration.compare(duration1, duration2, { relativeTo }); + +relativeTo = "1970-01-01T00:00:00-00:45[Africa/Monrovia]"; +result = action(relativeTo); +assert.sameValue(result, 0, "rounded HH:MM is accepted in string offset"); + +relativeTo = "1970-01-01T00:00:00-00:44:30[Africa/Monrovia]"; +result = action(relativeTo); +assert.sameValue(result, 0, "unrounded HH:MM:SS is accepted in string offset"); + +const timeZone = Temporal.TimeZone.from("Africa/Monrovia"); +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone }; +assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag"); diff --git a/test/intl402/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.js new file mode 100644 index 00000000000..f34fb1e43c0 --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/add/relativeto-sub-minute-offset.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.duration.prototype.add +description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(1, 0, 0, 1); +let result; +let relativeTo; +const action = (relativeTo) => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); + +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (property bag)"); + +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"); diff --git a/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js new file mode 100644 index 00000000000..aa0c86ce82f --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js @@ -0,0 +1,39 @@ +// 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.duration.prototype.round +description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +let result; +let relativeTo; + +const action = (relativeTo) => instance.round({ largestUnit: "years", relativeTo }); + +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "ISO string offset accepted with zero seconds (property bag)"); + +relativeTo = "1970-01-01T00:00:00-00:45[Africa/Monrovia]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "rounded HH:MM is accepted in string offset"); + +relativeTo = "1970-01-01T00:00:00-00:44:30[Africa/Monrovia]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "unrounded HH:MM:SS is accepted in string offset"); + +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"); + +const timeZone = Temporal.TimeZone.from("Africa/Monrovia"); +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone }; +assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag"); diff --git a/test/intl402/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js new file mode 100644 index 00000000000..f8420e487b8 --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset.js @@ -0,0 +1,26 @@ +// 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.duration.prototype.subtract +description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(1, 0, 0, 1); + +let result; +let relativeTo; +const action = (relativeTo) => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); + +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +TemporalHelpers.assertDateDuration(result, 1, 0, 0, 0, "ISO string offset accepted with zero seconds (property bag)"); + +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"); diff --git a/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js new file mode 100644 index 00000000000..a3e664ca31a --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js @@ -0,0 +1,38 @@ +// 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.duration.prototype.total +description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +let result; +let relativeTo; + +const action = (relativeTo) => instance.total({ unit: "days", relativeTo }); + +relativeTo = "1970-01-01T00:00-00:45:00[-00:45]"; +result = action(relativeTo); +assert.sameValue(result, 366, "ISO string offset accepted with zero seconds (string)"); + +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45:00.000000000", timeZone: "+00:45" }; +result = action(relativeTo); +assert.sameValue(result, 366, "ISO string offset accepted with zero seconds (property bag)"); + +relativeTo = "1970-01-01T00:00:00-00:45[Africa/Monrovia]"; +result = action(relativeTo); +assert.sameValue(result, 366, "rounded HH:MM is accepted in string offset"); + +relativeTo = "1970-01-01T00:00:00-00:44:30[Africa/Monrovia]"; +result = action(relativeTo); +assert.sameValue(result, 366, "unrounded HH:MM:SS is accepted in string offset"); + +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"); + +const timeZone = Temporal.TimeZone.from("Africa/Monrovia"); +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone }; +assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag"); diff --git a/test/intl402/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset.js new file mode 100644 index 00000000000..9a7d786d353 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset.js @@ -0,0 +1,103 @@ +// 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.from +description: Fuzzy matching behaviour with UTC offsets in ISO 8601 strings with named time zones and offset option +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +["use", "ignore", "prefer", "reject"].forEach((offset) => { + const result = Temporal.ZonedDateTime.from("1970-01-01T12:00-00:44:30[Africa/Monrovia]", { offset }); + assert.sameValue(result.epochNanoseconds, 45870_000_000_000n, `accepts the exact offset string (offset: ${offset})`); + assert.sameValue(result.offset, "-00:44:30", "offset property is correct"); +}); + +["use", "ignore", "prefer", "reject"].forEach((offset) => { + const result = Temporal.ZonedDateTime.from("1970-01-01T12:00-00:44:30.000000000[Africa/Monrovia]", { offset }); + assert.sameValue( + result.epochNanoseconds, + 45870_000_000_000n, + `accepts trailing zeroes after ISO string offset (offset: ${offset})` + ); + assert.sameValue(result.offset, "-00:44:30", "offset property removes trailing zeroes from input"); +}); + +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from("1970-01-01T00:00-00:44:30[-00:45]", { offset: "reject" }), + "minute rounding not supported for offset time zones" +); + +const str = "1970-01-01T12:00-00:45[Africa/Monrovia]"; + +["ignore", "prefer", "reject"].forEach((offset) => { + const result = Temporal.ZonedDateTime.from(str, { offset }); + assert.sameValue( + result.epochNanoseconds, + 45870_000_000_000n, + `accepts the offset string rounded to minutes (offset=${offset})` + ); + assert.sameValue(result.offset, "-00:44:30", "offset property is still the full precision"); + TemporalHelpers.assertPlainDateTime( + result.toPlainDateTime(), + 1970, + 1, + "M01", + 1, + 12, + 0, + 0, + 0, + 0, + 0, + "wall time is preserved" + ); +}); + +const result = Temporal.ZonedDateTime.from(str, { offset: "use" }); +assert.sameValue( + result.epochNanoseconds, + 45900_000_000_000n, + "prioritizes the offset string with HH:MM precision when offset=use" +); +assert.sameValue(result.offset, "-00:44:30", "offset property is still the full precision"); +TemporalHelpers.assertPlainDateTime( + result.toPlainDateTime(), + 1970, + 1, + "M01", + 1, + 12, + 0, + 30, + 0, + 0, + 0, + "wall time is shifted by the difference between exact and rounded offset" +); + +const properties = { year: 1970, month: 1, day: 1, hour: 12, offset: "-00:45", timeZone: "Africa/Monrovia" }; + +["ignore", "prefer"].forEach((offset) => { + const result = Temporal.ZonedDateTime.from(properties, { offset }); + assert.sameValue( + result.epochNanoseconds, + 45870_000_000_000n, + `no fuzzy matching is done on offset in property bag (offset=${offset})` + ); +}); + +const result2 = Temporal.ZonedDateTime.from(properties, { offset: "use" }); +assert.sameValue( + result2.epochNanoseconds, + 45900_000_000_000n, + "no fuzzy matching is done on offset in property bag (offset=use)" +); + +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(properties, { offset: "reject" }), + "no fuzzy matching is done on offset in property bag (offset=reject)" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js new file mode 100644 index 00000000000..fe058b4a7bf --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js @@ -0,0 +1,35 @@ +// 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.equals +description: Fuzzy matching behaviour for UTC offset in ISO 8601 string with named time zones +features: [Temporal] +---*/ + +const expectedNanoseconds = BigInt((44 * 60 + 30) * 1e9); +const timeZone = new Temporal.TimeZone("Africa/Monrovia"); +const instance = new Temporal.ZonedDateTime(expectedNanoseconds, timeZone); + +let result = instance.equals("1970-01-01T00:00:00-00:45[Africa/Monrovia]"); +assert.sameValue(result, true, "UTC offset rounded to minutes is accepted"); + +result = instance.equals("1970-01-01T00:00:00-00:44:30[Africa/Monrovia]"); +assert.sameValue(result, true, "Unrounded sub-minute UTC offset also accepted"); + +assert.throws( + RangeError, + () => instance.equals("1970-01-01T00:00:00-00:44:30[-00:45]"), + "minute rounding not supported for offset time zones" +); + +const properties = { + offset: "-00:45", + year: 1970, + month: 1, + day: 1, + minute: 44, + second: 30, + timeZone +}; +assert.throws(RangeError, () => instance.equals(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js new file mode 100644 index 00000000000..775dd0430c3 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js @@ -0,0 +1,48 @@ +// 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.since +description: Fuzzy matching behaviour for UTC offset in ISO 8601 string with named time zones +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("Africa/Monrovia"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +let result = instance.since("1970-01-01T00:44:30-00:44:30[Africa/Monrovia]"); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, -1, -29, 0, 0, 0, 0, "UTC offset rounded to minutes is accepted"); + +result = instance.since("1970-01-01T00:44:30-00:44:30[Africa/Monrovia]"); +TemporalHelpers.assertDuration( + result, + 0, + 0, + 0, + 0, + -1, + -29, + 0, + 0, + 0, + 0, + "Unrounded sub-minute UTC offset also accepted" +); + +assert.throws( + RangeError, + () => instance.since("1970-01-01T00:44:30+00:44:30[+00:45"), + "minute rounding not supported for offset time zones" +); + +const properties = { + offset: "-00:45", + year: 1970, + month: 1, + day: 1, + minute: 44, + second: 30, + timeZone +}; +assert.throws(RangeError, () => instance.since(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js new file mode 100644 index 00000000000..e1081896713 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js @@ -0,0 +1,35 @@ +// 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.until +description: Fuzzy matching behaviour for UTC offset in ISO 8601 string with named time zones +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("Africa/Monrovia"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +let result = instance.until("1970-01-01T00:44:30-00:44:30[Africa/Monrovia]"); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 1, 29, 0, 0, 0, 0, "UTC offset rounded to minutes is accepted"); + +result = instance.until("1970-01-01T00:44:30-00:44:30[Africa/Monrovia]"); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 1, 29, 0, 0, 0, 0, "Unrounded sub-minute UTC offset also accepted"); + +assert.throws( + RangeError, + () => instance.until("1970-01-01T00:44:30+00:44:30[+00:45"), + "minute rounding not supported for offset time zones" +); + +const properties = { + offset: "-00:45", + year: 1970, + month: 1, + day: 1, + minute: 44, + second: 30, + timeZone +}; +assert.throws(RangeError, () => instance.until(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js similarity index 63% rename from test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js rename to test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js index b0d202e678a..ed5c00b7cfd 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js @@ -3,26 +3,52 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.with -description: Fuzzy matching behaviour with UTC offsets in ISO 8601 strings and offset option +description: Fuzzy matching behaviour with UTC offsets in ISO 8601 strings with named time zones and offset option includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("-00:44:30.123456789"); +const timeZone = new Temporal.TimeZone("Africa/Monrovia"); const instance = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, hour: 12, timeZone }); -assert.sameValue(instance.offset, "-00:44:30.123456789", "original offset"); +assert.sameValue(instance.offset, "-00:44:30", "original offset"); const properties = { day: 2, offset: "-00:45" }; ["ignore", "prefer"].forEach((offset) => { const result = instance.with(properties, { offset }); - assert.sameValue(result.epochNanoseconds, 132270_123_456_789n, `ignores new offset (offset=${offset})`); + assert.sameValue(result.epochNanoseconds, 132270_000_000_000n, `ignores new offset (offset=${offset})`); assert.sameValue(result.offset, instance.offset, "offset property is unchanged"); - TemporalHelpers.assertPlainDateTime(result.toPlainDateTime(), 1970, 1, "M01", 2, 12, 0, 0, 0, 0, 0, "wall time is not shifted"); + TemporalHelpers.assertPlainDateTime( + result.toPlainDateTime(), + 1970, + 1, + "M01", + 2, + 12, + 0, + 0, + 0, + 0, + 0, + "wall time is not shifted" + ); }); const result = instance.with(properties, { offset: "use" }); assert.sameValue(result.epochNanoseconds, 132300_000_000_000n, "accepts HH:MM rounded offset (offset=use)"); assert.sameValue(result.offset, instance.offset, "offset property is unchanged"); -TemporalHelpers.assertPlainDateTime(result.toPlainDateTime(), 1970, 1, "M01", 2, 12, 0, 29, 876, 543, 211, "wall time is shifted by the difference between exact and rounded offset"); +TemporalHelpers.assertPlainDateTime( + result.toPlainDateTime(), + 1970, + 1, + "M01", + 2, + 12, + 0, + 30, + 0, + 0, + 0, + "wall time is shifted by the difference between exact and rounded offset" +); assert.throws(RangeError, () => instance.with(properties, { offset: "reject" }), "no fuzzy matching is done in with()"); diff --git a/test/staging/Temporal/Duration/old/add.js b/test/staging/Temporal/Duration/old/add.js index a74e8ed3e3a..52075623d61 100644 --- a/test/staging/Temporal/Duration/old/add.js +++ b/test/staging/Temporal/Duration/old/add.js @@ -116,20 +116,6 @@ assert.sameValue(`${ oneDay.add(hours24, { // throws on wrong offset for ZonedDateTime relativeTo string assert.throws(RangeError, () => oneDay.add(hours24, { relativeTo: "1971-01-01T00:00+02:00[-00:44:30]" })); -// does not throw on HH:MM rounded offset for ZonedDateTime relativeTo string -assert.sameValue(`${ oneDay.add(hours24, { relativeTo: "1971-01-01T00:00-00:45[-00:44:30]" }) }`, "P2D"); - -// throws on HH:MM rounded offset for ZonedDateTime relativeTo property bag -assert.throws(RangeError, () => oneDay.add(hours24, { - relativeTo: { - year: 1971, - month: 1, - day: 1, - offset: "-00:45", - timeZone: "-00:44:30" - } -})); - // at least the required properties must be present in relativeTo assert.throws(TypeError, () => oneDay.add(hours24, { relativeTo: { diff --git a/test/staging/Temporal/Duration/old/round.js b/test/staging/Temporal/Duration/old/round.js index 245d79a61e4..b7fd879a062 100644 --- a/test/staging/Temporal/Duration/old/round.js +++ b/test/staging/Temporal/Duration/old/round.js @@ -229,24 +229,6 @@ assert.throws(RangeError, () => d.round({ relativeTo: "1971-01-01T00:00+02:00[-00:44:30]" })); -// does not throw on HH:MM rounded offset for ZonedDateTime relativeTo string -assert.sameValue(`${ d.round({ - smallestUnit: "seconds", - relativeTo: "1971-01-01T00:00-00:45[-00:44:30]" -}) }`, "P5Y5M5W5DT5H5M5S"); - -// throws on HH:MM rounded offset for ZonedDateTime relativeTo property bag -assert.throws(RangeError, () => d.round({ - smallestUnit: "seconds", - relativeTo: { - year: 1971, - month: 1, - day: 1, - offset: "-00:45", - timeZone: "-00:44:30" - } -})); - // relativeTo object must contain at least the required correctly-spelled properties assert.throws(TypeError, () => hours25.round({ largestUnit: "days", diff --git a/test/staging/Temporal/Duration/old/subtract.js b/test/staging/Temporal/Duration/old/subtract.js index 1b9307c64d7..776038ca7fb 100644 --- a/test/staging/Temporal/Duration/old/subtract.js +++ b/test/staging/Temporal/Duration/old/subtract.js @@ -81,20 +81,6 @@ assert.sameValue(`${ oneDay.subtract(hours24, { // throws on wrong offset for ZonedDateTime relativeTo string assert.throws(RangeError, () => oneDay.subtract(hours24, { relativeTo: "1971-01-01T00:00+02:00[-00:44:30]" })); -// does not throw on HH:MM rounded offset for ZonedDateTime relativeTo string -assert.sameValue(`${ oneDay.subtract(hours24, { relativeTo: "1971-01-01T00:00-00:45[-00:44:30]" }) }`, "PT0S"); - -// throws on HH:MM rounded offset for ZonedDateTime relativeTo property bag -assert.throws(RangeError, () => oneDay.subtract(hours24, { - relativeTo: { - year: 1971, - month: 1, - day: 1, - offset: "-00:45", - timeZone: "-00:44:30" - } -})); - // at least the required properties must be present in relativeTo assert.throws(TypeError, () => oneDay.subtract(hours24, { relativeTo: { diff --git a/test/staging/Temporal/Duration/old/total.js b/test/staging/Temporal/Duration/old/total.js index 67e852888df..31216e09991 100644 --- a/test/staging/Temporal/Duration/old/total.js +++ b/test/staging/Temporal/Duration/old/total.js @@ -76,25 +76,6 @@ assert.throws(RangeError, () => d.total({ relativeTo: "1971-01-01T00:00+02:00[-00:44:30]" })); -// does not throw on HH:MM rounded offset for ZonedDateTime relativeTo string -var oneMonth = Temporal.Duration.from({ months: 1 }); -assert.sameValue(oneMonth.total({ - unit: "months", - relativeTo: "1971-01-01T00:00-00:45[-00:44:30]" -}), 1); - -// throws on HH:MM rounded offset for ZonedDateTime relativeTo property bag -assert.throws(RangeError, () => d.total({ - unit: "months", - relativeTo: { - year: 1971, - month: 1, - day: 1, - offset: "-00:45", - timeZone: "-00:44:30" - } -})); - // relativeTo object must contain at least the required correctly-spelled properties assert.throws(TypeError, () => d.total({ unit: "months", diff --git a/test/staging/Temporal/Regex/old/timezone.js b/test/staging/Temporal/Regex/old/timezone.js index 13f9b3db5de..100adc14e60 100644 --- a/test/staging/Temporal/Regex/old/timezone.js +++ b/test/staging/Temporal/Regex/old/timezone.js @@ -19,11 +19,7 @@ function generateTest(dateTimeString, zoneString, expectedName) { [ "+00:00", "+00", - "+0000", - "+00:00:00", - "+000000", - "+00:00:00.000000000", - "+000000.0" + "+0000" ].forEach(zoneString => { generateTest("1976-11-18T15:23", `${ zoneString }[UTC]`, "UTC"); generateTest("1976-11-18T15:23", `+00:00[${ zoneString }]`, "+00:00"); @@ -31,11 +27,7 @@ function generateTest(dateTimeString, zoneString, expectedName) { [ "-04:00", "-04", - "-0400", - "-04:00:00", - "-040000", - "-04:00:00.000000000", - "-040000.0" + "-0400" ].forEach(zoneString => generateTest("1976-11-18T15:23", zoneString, "-04:00")); [ "1", @@ -48,7 +40,6 @@ function generateTest(dateTimeString, zoneString, expectedName) { "12345678" ].forEach(decimals => { test(`1976-11-18T15:23:30.${ decimals }Z`, "UTC"); - test(`1976-11-18T15:23+01:00[+01:00:00.${ decimals }]`, `+01:00:00.${ decimals }`); }); generateTest("1976-11-18T15:23", "z", "UTC"); test("1976-11-18T15:23:30,1234Z", "UTC"); @@ -92,9 +83,6 @@ test("\u221200", "+00:00"); test("\u22120300", "-03:00"); test("\u221203:00", "-03:00"); test("\u221203", "-03:00"); -test("+030000.0", "+03:00"); -test("-03:00:00", "-03:00"); -test("-03:00:00.000000000", "-03:00"); test("1976-11-18T15:23:30.123456789Z[u-ca=iso8601]", "UTC"); test("1976-11-18T15:23:30.123456789-04:00[u-ca=iso8601]", "-04:00"); test("1976-11-18T15:23:30.123456789[UTC][u-ca=iso8601]", "UTC"); diff --git a/test/staging/Temporal/TimeZone/old/getInstantFor.js b/test/staging/Temporal/TimeZone/old/getInstantFor.js index 8eda2c0f84e..4569e2213b9 100644 --- a/test/staging/Temporal/TimeZone/old/getInstantFor.js +++ b/test/staging/Temporal/TimeZone/old/getInstantFor.js @@ -31,10 +31,10 @@ assert.sameValue(`${ tz.getInstantFor(dt) }`, "-001000-10-29T04:46:38.271986102Z // year 0 leap day var dt = Temporal.PlainDateTime.from("0000-02-29T00:00"); -var tz = Temporal.TimeZone.from("-00:01:15"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-02-29T00:01:15Z"); +var tz = Temporal.TimeZone.from("-00:01"); +assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-02-29T00:01:00Z"); dt = Temporal.PlainDateTime.from("+000000-02-29T00:00"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-02-29T00:01:15Z"); +assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-02-29T00:01:00Z"); // outside of Instant range var max = Temporal.PlainDateTime.from("+275760-09-13T23:59:59.999999999"); diff --git a/test/staging/Temporal/TimeZone/old/subminute-offset.js b/test/staging/Temporal/TimeZone/old/subminute-offset.js deleted file mode 100644 index 657d2d0d7fb..00000000000 --- a/test/staging/Temporal/TimeZone/old/subminute-offset.js +++ /dev/null @@ -1,14 +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-timezone-objects -description: sub-minute offset -features: [Temporal] ----*/ - -var zone = new Temporal.TimeZone("+00:19:32"); -var inst = Temporal.Instant.from("2000-01-01T12:00Z"); -var dtm = Temporal.PlainDateTime.from("2000-01-01T12:00"); -assert.sameValue(zone.getOffsetNanosecondsFor(inst), 1172000000000); -assert.sameValue(`${ zone.getInstantFor(dtm) }`, "2000-01-01T11:40:28Z"); diff --git a/test/staging/Temporal/UserTimezone/old/subminute-offset.js b/test/staging/Temporal/UserTimezone/old/subminute-offset.js index 4d6e925aeb8..0d37600973d 100644 --- a/test/staging/Temporal/UserTimezone/old/subminute-offset.js +++ b/test/staging/Temporal/UserTimezone/old/subminute-offset.js @@ -9,7 +9,7 @@ features: [Temporal] class SubminuteTimeZone extends Temporal.TimeZone { constructor() { - super("-00:00:01.111111111"); + super("UTC"); } get id() { return "Custom/Subminute"; diff --git a/test/staging/Temporal/ZonedDateTime/old/property-bags.js b/test/staging/Temporal/ZonedDateTime/old/property-bags.js index e49838a08ce..21d3f134528 100644 --- a/test/staging/Temporal/ZonedDateTime/old/property-bags.js +++ b/test/staging/Temporal/ZonedDateTime/old/property-bags.js @@ -288,6 +288,6 @@ var zdt = Temporal.ZonedDateTime.from({ month: 1, day: 1, hour: 12, - timeZone: "-00:44:30" + timeZone: TemporalHelpers.specificOffsetTimeZone(-2.67e12) // -00:44:30 in nanoseconds }); assert.sameValue(zdt.offset, "-00:44:30"); diff --git a/test/staging/Temporal/ZonedDateTime/old/toInstant.js b/test/staging/Temporal/ZonedDateTime/old/toInstant.js index 7ca369f843d..32a3061f06e 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toInstant.js +++ b/test/staging/Temporal/ZonedDateTime/old/toInstant.js @@ -27,7 +27,7 @@ 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:15[-00:01:15]"); -assert.sameValue(`${ zdt.toInstant() }`, "0000-02-29T00:01:15Z"); -zdt = Temporal.ZonedDateTime.from("+000000-02-29T00:00-00:01:15[-00:01:15]"); -assert.sameValue(`${ zdt.toInstant() }`, "0000-02-29T00:01:15Z"); +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");