| 1 |
// |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options |
| 2 |
// Copyright (C) 2022 Igalia, S.L. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-temporal.instant.from |
| 7 |
description: Temporal.Instant string with sub-minute offset |
| 8 |
features: [Temporal] |
| 9 |
---*/ |
| 10 |
|
| 11 |
const str = "1970-01-01T00:19:32.37+00:19:32.37"; |
| 12 |
const result = Temporal.Instant.from(str); |
| 13 |
assert.sameValue(result.epochNanoseconds, 0n, "if present, sub-minute offset is accepted exactly"); |
| 14 |
|
| 15 |
[ |
| 16 |
"2021-08-19T17:30-07:00:01[-07:00:01]", |
| 17 |
"2021-08-19T17:30-07:00:00[-07:00:00]", |
| 18 |
"2021-08-19T17:30-07:00:00.1[-07:00:00.1]", |
| 19 |
"2021-08-19T17:30-07:00:00.0[-07:00:00.0]", |
| 20 |
"2021-08-19T17:30-07:00:00.01[-07:00:00.01]", |
| 21 |
"2021-08-19T17:30-07:00:00.00[-07:00:00.00]", |
| 22 |
"2021-08-19T17:30-07:00:00.001[-07:00:00.001]", |
| 23 |
"2021-08-19T17:30-07:00:00.000[-07:00:00.000]", |
| 24 |
"2021-08-19T17:30-07:00:00.0001[-07:00:00.0001]", |
| 25 |
"2021-08-19T17:30-07:00:00.0000[-07:00:00.0000]", |
| 26 |
"2021-08-19T17:30-07:00:00.00001[-07:00:00.00001]", |
| 27 |
"2021-08-19T17:30-07:00:00.00000[-07:00:00.00000]", |
| 28 |
"2021-08-19T17:30-07:00:00.000001[-07:00:00.000001]", |
| 29 |
"2021-08-19T17:30-07:00:00.000000[-07:00:00.000000]", |
| 30 |
"2021-08-19T17:30-07:00:00.0000001[-07:00:00.0000001]", |
| 31 |
"2021-08-19T17:30-07:00:00.0000000[-07:00:00.0000000]", |
| 32 |
"2021-08-19T17:30-07:00:00.00000001[-07:00:00.00000001]", |
| 33 |
"2021-08-19T17:30-07:00:00.00000000[-07:00:00.00000000]", |
| 34 |
"2021-08-19T17:30-07:00:00.000000001[-07:00:00.000000001]", |
| 35 |
"2021-08-19T17:30-07:00:00.000000000[-07:00:00.000000000]", |
| 36 |
|
| 37 |
"2021-08-19T17:30-07:00:01[-070001]", |
| 38 |
"2021-08-19T17:30-07:00:00[-070000]", |
| 39 |
"2021-08-19T17:30-07:00:00.1[-070000.1]", |
| 40 |
"2021-08-19T17:30-07:00:00.0[-070000.0]", |
| 41 |
"2021-08-19T17:30-07:00:00.01[-070000.01]", |
| 42 |
"2021-08-19T17:30-07:00:00.00[-070000.00]", |
| 43 |
"2021-08-19T17:30-07:00:00.001[-070000.001]", |
| 44 |
"2021-08-19T17:30-07:00:00.000[-070000.000]", |
| 45 |
"2021-08-19T17:30-07:00:00.0001[-070000.0001]", |
| 46 |
"2021-08-19T17:30-07:00:00.0000[-070000.0000]", |
| 47 |
"2021-08-19T17:30-07:00:00.00001[-070000.00001]", |
| 48 |
"2021-08-19T17:30-07:00:00.00000[-070000.00000]", |
| 49 |
"2021-08-19T17:30-07:00:00.000001[-070000.000001]", |
| 50 |
"2021-08-19T17:30-07:00:00.000000[-070000.000000]", |
| 51 |
"2021-08-19T17:30-07:00:00.0000001[-070000.0000001]", |
| 52 |
"2021-08-19T17:30-07:00:00.0000000[-070000.0000000]", |
| 53 |
"2021-08-19T17:30-07:00:00.00000001[-070000.00000001]", |
| 54 |
"2021-08-19T17:30-07:00:00.00000000[-070000.00000000]", |
| 55 |
"2021-08-19T17:30-07:00:00.000000001[-070000.000000001]", |
| 56 |
"2021-08-19T17:30-07:00:00.000000000[-070000.000000000]" |
| 57 |
].forEach((str) => { |
| 58 |
assert.throws( |
| 59 |
RangeError, |
| 60 |
() => Temporal.Instant.from(str), |
| 61 |
`ISO strings cannot have sub-minute offsets in time zone annotations: ${str}` |
| 62 |
); |
| 63 |
}); |
| 64 |
|
| 65 |
reportCompare(0, 0); |