mirror of https://github.com/tc39/test262.git
Test ISO strings with multiple fractional second parts
Tests for the normative changes made to Temporal in https://github.com/tc39/proposal-temporal/pull/1796
This commit is contained in:
parent
0b8319355b
commit
9c5ec87dba
|
@ -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)");
|
|
@ -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");
|
14
test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js
vendored
Normal file
14
test/built-ins/Temporal/Instant/prototype/equals/instant-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
15
test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js
vendored
Normal file
15
test/built-ins/Temporal/Instant/prototype/since/instant-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
16
test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/Instant/prototype/toString/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
16
test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
16
test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
15
test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js
vendored
Normal file
15
test/built-ins/Temporal/Instant/prototype/until/instant-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
|
@ -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");
|
|
@ -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");
|
16
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
|
@ -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");
|
16
test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
|
@ -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");
|
|
@ -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");
|
|
@ -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)");
|
|
@ -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");
|
|
@ -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");
|
20
test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-multiple-offsets.js
vendored
Normal file
20
test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
15
test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js
vendored
Normal file
15
test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
19
test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-multiple-offsets.js
vendored
Normal file
19
test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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 } });
|
16
test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
19
test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-multiple-offsets.js
vendored
Normal file
19
test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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 } });
|
16
test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
16
test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js
vendored
Normal file
16
test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets.js
vendored
Normal file
|
@ -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");
|
Loading…
Reference in New Issue