Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-string-date-with-utc-offset.js

raw
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.plaindate.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 "2000-05-02T00+00:00",
14 "2000-05-02T00+00:00[UTC]",
15 "2000-05-02T00+00:00[!UTC]",
16 "2000-05-02T00-02:30[America/St_Johns]",
17 ];
18
19 for (const arg of validStrings) {
20 const result = Temporal.PlainDate.from(arg);
21
22 TemporalHelpers.assertPlainDate(
23 result,
24 2000, 5, "M05", 2,
25 `"${arg}" is a valid UTC offset with time for PlainDate`
26 );
27 }
28
29 const invalidStrings = [
30 "2022-09-15Z",
31 "2022-09-15Z[UTC]",
32 "2022-09-15Z[Europe/Vienna]",
33 "2022-09-15+00:00",
34 "2022-09-15+00:00[UTC]",
35 "2022-09-15-02:30",
36 "2022-09-15-02:30[America/St_Johns]",
37 ];
38
39 for (const arg of invalidStrings) {
40 assert.throws(
41 RangeError,
42 () => Temporal.PlainDate.from(arg),
43 `"${arg}" UTC offset without time is not valid for PlainDate`
44 );
45 }
46
47 reportCompare(0, 0);