| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2021 Igalia, S.L. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
/*--- |
| 5 |
esid: sec-temporal.now.plaindatetimeiso |
| 6 |
description: Conversion of ISO date-time strings to Temporal.TimeZone instances |
| 7 |
features: [Temporal] |
| 8 |
---*/ |
| 9 |
|
| 10 |
let timeZone = "2021-08-19T17:30"; |
| 11 |
assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), "bare date-time string is not a time zone"); |
| 12 |
|
| 13 |
[ |
| 14 |
"2021-08-19T17:30-07:00:01", |
| 15 |
"2021-08-19T17:30-07:00:00", |
| 16 |
"2021-08-19T17:30-07:00:00.1", |
| 17 |
"2021-08-19T17:30-07:00:00.0", |
| 18 |
"2021-08-19T17:30-07:00:00.01", |
| 19 |
"2021-08-19T17:30-07:00:00.00", |
| 20 |
"2021-08-19T17:30-07:00:00.001", |
| 21 |
"2021-08-19T17:30-07:00:00.000", |
| 22 |
"2021-08-19T17:30-07:00:00.0001", |
| 23 |
"2021-08-19T17:30-07:00:00.0000", |
| 24 |
"2021-08-19T17:30-07:00:00.00001", |
| 25 |
"2021-08-19T17:30-07:00:00.00000", |
| 26 |
"2021-08-19T17:30-07:00:00.000001", |
| 27 |
"2021-08-19T17:30-07:00:00.000000", |
| 28 |
"2021-08-19T17:30-07:00:00.0000001", |
| 29 |
"2021-08-19T17:30-07:00:00.0000000", |
| 30 |
"2021-08-19T17:30-07:00:00.00000001", |
| 31 |
"2021-08-19T17:30-07:00:00.00000000", |
| 32 |
"2021-08-19T17:30-07:00:00.000000001", |
| 33 |
"2021-08-19T17:30-07:00:00.000000000", |
| 34 |
].forEach((timeZone) => { |
| 35 |
assert.throws( |
| 36 |
RangeError, |
| 37 |
() => Temporal.Now.plainDateTimeISO(timeZone), |
| 38 |
`ISO string ${timeZone} with a sub-minute offset is not a valid time zone` |
| 39 |
); |
| 40 |
}); |
| 41 |
|
| 42 |
// The following are all valid strings so should not throw: |
| 43 |
|
| 44 |
[ |
| 45 |
"2021-08-19T17:30Z", |
| 46 |
"2021-08-19T1730Z", |
| 47 |
"2021-08-19T17:30-07:00", |
| 48 |
"2021-08-19T1730-07:00", |
| 49 |
"2021-08-19T17:30-0700", |
| 50 |
"2021-08-19T1730-0700", |
| 51 |
"2021-08-19T17:30[America/Vancouver]", |
| 52 |
"2021-08-19T1730[America/Vancouver]", |
| 53 |
"2021-08-19T17:30Z[America/Vancouver]", |
| 54 |
"2021-08-19T1730Z[America/Vancouver]", |
| 55 |
"2021-08-19T17:30-07:00[America/Vancouver]", |
| 56 |
"2021-08-19T1730-07:00[America/Vancouver]", |
| 57 |
"2021-08-19T17:30-0700[America/Vancouver]", |
| 58 |
"2021-08-19T1730-0700[America/Vancouver]", |
| 59 |
].forEach((timeZone) => { |
| 60 |
Temporal.Now.plainDateTimeISO(timeZone); |
| 61 |
}); |
| 62 |
|
| 63 |
reportCompare(0, 0); |