| 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.plainmonthday.from |
| 7 |
description: UTC offset not valid with format that does not include a time |
| 8 |
features: [Temporal] |
| 9 |
includes: [temporalHelpers.js] |
| 10 |
---*/ |
| 11 |
|
| 12 |
const validStrings = [ |
| 13 |
"05-02[Asia/Katmandu]", |
| 14 |
"05-02[!Asia/Katmandu]", |
| 15 |
"05-02[u-ca=iso8601]", |
| 16 |
"05-02[Asia/Tokyo][u-ca=iso8601]", |
| 17 |
"--05-02[Asia/Katmandu]", |
| 18 |
"--05-02[!Asia/Katmandu]", |
| 19 |
"--05-02[u-ca=iso8601]", |
| 20 |
"--05-02[Asia/Tokyo][u-ca=iso8601]", |
| 21 |
"2000-05-02T00+00:00", |
| 22 |
"2000-05-02T00+00:00[UTC]", |
| 23 |
"2000-05-02T00-02:30[America/St_Johns]", |
| 24 |
]; |
| 25 |
|
| 26 |
for (const arg of validStrings) { |
| 27 |
const result = Temporal.PlainMonthDay.from(arg); |
| 28 |
|
| 29 |
TemporalHelpers.assertPlainMonthDay( |
| 30 |
result, |
| 31 |
"M05", 2, |
| 32 |
`"${arg}" is a valid UTC offset with time for PlainMonthDay` |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
const invalidStrings = [ |
| 37 |
"09-15Z", |
| 38 |
"09-15Z[UTC]", |
| 39 |
"09-15+01:00", |
| 40 |
"09-15+01:00[Europe/Vienna]", |
| 41 |
"--09-15Z", |
| 42 |
"--09-15Z[UTC]", |
| 43 |
"--09-15+01:00", |
| 44 |
"--09-15+01:00[Europe/Vienna]", |
| 45 |
"2022-09-15Z", |
| 46 |
"2022-09-15Z[UTC]", |
| 47 |
"2022-09-15Z[Europe/Vienna]", |
| 48 |
"2022-09-15+00:00", |
| 49 |
"2022-09-15+00:00[UTC]", |
| 50 |
"2022-09-15-02:30", |
| 51 |
"2022-09-15-02:30[America/St_Johns]", |
| 52 |
"09-15[u-ca=chinese]", |
| 53 |
]; |
| 54 |
|
| 55 |
for (const arg of invalidStrings) { |
| 56 |
assert.throws( |
| 57 |
RangeError, |
| 58 |
() => Temporal.PlainMonthDay.from(arg), |
| 59 |
`"${arg}" UTC offset without time is not valid for PlainMonthDay` |
| 60 |
); |
| 61 |
} |
| 62 |
|
| 63 |
reportCompare(0, 0); |