diff options
Diffstat (limited to 'js/src/tests/test262/intl402/Temporal/Instant/prototype/toString')
4 files changed, 47 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js new file mode 100644 index 0000000000..927a2ff6c3 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js @@ -0,0 +1,22 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// 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: The time zone offset part of the string serialization (IANA time zones) +features: [BigInt, Temporal] +---*/ + +const instant = new Temporal.Instant(0n); + +function test(timeZoneIdentifier, expected, description) { + const timeZone = new Temporal.TimeZone(timeZoneIdentifier); + assert.sameValue(instant.toString({ timeZone }), expected, description); +} + +test("Europe/Berlin", "1970-01-01T01:00:00+01:00", "positive offset"); +test("America/New_York", "1969-12-31T19:00:00-05:00", "negative offset"); +test("Africa/Monrovia", "1969-12-31T23:15:30-00:45", "sub-minute offset"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js new file mode 100644 index 0000000000..f25a7e147f --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2022 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: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +let timeZone = "2021-08-19T17:30[America/Vancouver]"; +const result1 = instance.toString({ timeZone }); +assert.sameValue(result1.substr(-6), "-08:00", "date-time + IANA annotation is the IANA time zone"); + +timeZone = "2021-08-19T17:30Z[America/Vancouver]"; +const result2 = instance.toString({ timeZone }); +assert.sameValue(result2.substr(-6), "-08:00", "date-time + Z + IANA annotation is the IANA time zone"); + +timeZone = "2021-08-19T17:30-07:00[America/Vancouver]"; +const result3 = instance.toString({ timeZone }); +assert.sameValue(result3.substr(-6), "-08:00", "date-time + offset + IANA annotation is the IANA time zone"); + +reportCompare(0, 0); |