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 new file mode 100644 index 0000000000..1417e3dc94 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/instant-string-multiple-offsets.js @@ -0,0 +1,14 @@ +// 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.instant.compare +description: Instant strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const epoch = new Temporal.Instant(0n); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +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 new file mode 100644 index 0000000000..b8f6178d05 --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/instant-string-multiple-offsets.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.from +description: Instant strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +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 new file mode 100644 index 0000000000..7f8d1bcc07 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js @@ -0,0 +1,14 @@ +// 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.instant.prototype.equals +description: Instant strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +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 new file mode 100644 index 0000000000..6bf08bef5e --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.since +description: Instant strings with UTC offset fractional part are not confused with time fractional part +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +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-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js new file mode 100644 index 0000000000..9d118c093e --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.instant.prototype.tostring +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = instance.toString({ timeZone }); +assert.sameValue(result1.substr(-6), "+01:46", "Time zone string determined from offset"); +const result2 = instance.toString({ timeZone: { timeZone } }); +assert.sameValue(result2.substr(-6), "+01:46", "Time zone string determined from offset"); 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 new file mode 100644 index 0000000000..793bbe8988 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.instant.prototype.tozoneddatetime +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "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 new file mode 100644 index 0000000000..16ce94429c --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.instant.prototype.tozoneddatetimeiso +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = instance.toZonedDateTimeISO(timeZone); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = instance.toZonedDateTimeISO({ timeZone }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "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 new file mode 100644 index 0000000000..5b6300473e --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.until +description: Instant strings with UTC offset fractional part are not confused with time fractional part +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +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 new file mode 100644 index 0000000000..a7fbcb202b --- /dev/null +++ b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.now.zoneddatetime +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = Temporal.Now.zonedDateTime("iso8601", timeZone); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = Temporal.Now.zonedDateTime("iso8601", { timeZone }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "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 new file mode 100644 index 0000000000..676e54c03c --- /dev/null +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.now.zoneddatetimeiso +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = Temporal.Now.zonedDateTimeISO(timeZone); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = Temporal.Now.zonedDateTimeISO({ timeZone }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); 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 new file mode 100644 index 0000000000..5b3dcdbf3b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.plaindate.prototype.tozoneddatetime +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +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 result1 = instance.toZonedDateTime(timeZone); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = instance.toZonedDateTime({ timeZone }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); 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 new file mode 100644 index 0000000000..5e089b44d9 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.plaindatetime.prototype.tozoneddatetime +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +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 result1 = instance.toZonedDateTime(timeZone); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = instance.toZonedDateTime({ timeZone }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); 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 new file mode 100644 index 0000000000..fbbad90453 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.plaintime.prototype.tozoneddatetime +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone: { timeZone } }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); 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 new file mode 100644 index 0000000000..85693acae9 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.from +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = Temporal.TimeZone.from(timeZone); +assert.sameValue(result1.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = Temporal.TimeZone.from({ timeZone }); +assert.sameValue(result2.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); 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 new file mode 100644 index 0000000000..a0a525a447 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getplaindatetimefor +description: Instant strings with UTC offset fractional part are not confused with time fractional part +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +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/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js new file mode 100644 index 0000000000..25a27a21f2 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets.js @@ -0,0 +1,14 @@ +// 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.compare +description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +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]"; + +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)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/from/timezone-string-multiple-offsets.js new file mode 100644 index 0000000000..5b6d5264c6 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/timezone-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: { timeZone } }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "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 new file mode 100644 index 0000000000..06191770f6 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string-multiple-offsets.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +const result = Temporal.ZonedDateTime.from(str); +assert.sameValue(result.timeZone.toString(), "+00:01:30.987654321", "Time zone determined from bracket name"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-multiple-offsets.js new file mode 100644 index 0000000000..2e2d7a84bb --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-multiple-offsets.js @@ -0,0 +1,20 @@ +// 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: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const expectedTimeZone = "+01:45:30.987654321"; +const instance = new Temporal.ZonedDateTime(0n, expectedTimeZone); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +// These operations 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 }; +assert(instance.equals({ ...properties, timeZone }), "time zone string should produce expected time zone"); +assert(instance.equals({ ...properties, timeZone: { timeZone } }), "time zone string should produce expected time zone"); 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 new file mode 100644 index 0000000000..ae485b1912 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("+00:01:30.987654321"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +const result = instance.equals(str); +assert.sameValue(result, false, "Time zone determined from bracket name"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-multiple-offsets.js new file mode 100644 index 0000000000..94426467cf --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-multiple-offsets.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const expectedTimeZone = "+01:45:30.987654321"; +const instance = new Temporal.ZonedDateTime(0n, expectedTimeZone); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +// These operations should produce expectedTimeZone, so the following operations +// should not throw due to the time zones being different on the receiver and +// the argument. + +instance.since({ year: 2020, month: 5, day: 2, timeZone }); +instance.since({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }); 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 new file mode 100644 index 0000000000..f28b3d847e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("+00:01:30.987654321"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +const result = instance.since(str); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, -29, -12, -345, -679, "Time zone determined from bracket name"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-multiple-offsets.js new file mode 100644 index 0000000000..1adbcb4239 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-multiple-offsets.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const expectedTimeZone = "+01:45:30.987654321"; +const instance = new Temporal.ZonedDateTime(0n, expectedTimeZone); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +// These operations should produce expectedTimeZone, so the following operations +// should not throw due to the time zones being different on the receiver and +// the argument. + +instance.until({ year: 2020, month: 5, day: 2, timeZone }); +instance.until({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }); 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 new file mode 100644 index 0000000000..230d40d1b1 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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: ZonedDateTime strings with UTC offset fractional part are not confused with time fractional part +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("+00:01:30.987654321"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +const str = "1970-01-01T00:02:00.000000000+00:02[+00:01:30.987654321]"; + +const result = instance.until(str); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 29, 12, 345, 679, "Time zone determined from bracket name"); 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 new file mode 100644 index 0000000000..e2246488f6 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js @@ -0,0 +1,16 @@ +// 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.withtimezone +description: Time zone strings with UTC offset fractional part are not confused with time fractional part +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); +const timeZone = "2021-08-19T17:30:45.123456789+01:46[+01:45:30.987654321]"; + +const result1 = instance.withTimeZone(timeZone); +assert.sameValue(result1.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name"); +const result2 = instance.withTimeZone({ timeZone }); +assert.sameValue(result2.timeZone.id, "+01:45:30.987654321", "Time zone string determined from bracket name");