summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Instant/from/instant-string-sub-minute-offset.js
blob: fb1591d7ac39cc9c11287415d8eb59f3b960665c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// |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.from
description: Temporal.Instant string with sub-minute offset
features: [Temporal]
---*/

const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result = Temporal.Instant.from(str);
assert.sameValue(result.epochNanoseconds, 0n, "if present, sub-minute offset is accepted exactly");

[
  "2021-08-19T17:30-07:00:01[-07:00:01]",
  "2021-08-19T17:30-07:00:00[-07:00:00]",
  "2021-08-19T17:30-07:00:00.1[-07:00:00.1]",
  "2021-08-19T17:30-07:00:00.0[-07:00:00.0]",
  "2021-08-19T17:30-07:00:00.01[-07:00:00.01]",
  "2021-08-19T17:30-07:00:00.00[-07:00:00.00]",
  "2021-08-19T17:30-07:00:00.001[-07:00:00.001]",
  "2021-08-19T17:30-07:00:00.000[-07:00:00.000]",
  "2021-08-19T17:30-07:00:00.0001[-07:00:00.0001]",
  "2021-08-19T17:30-07:00:00.0000[-07:00:00.0000]",
  "2021-08-19T17:30-07:00:00.00001[-07:00:00.00001]",
  "2021-08-19T17:30-07:00:00.00000[-07:00:00.00000]",
  "2021-08-19T17:30-07:00:00.000001[-07:00:00.000001]",
  "2021-08-19T17:30-07:00:00.000000[-07:00:00.000000]",
  "2021-08-19T17:30-07:00:00.0000001[-07:00:00.0000001]",
  "2021-08-19T17:30-07:00:00.0000000[-07:00:00.0000000]",
  "2021-08-19T17:30-07:00:00.00000001[-07:00:00.00000001]",
  "2021-08-19T17:30-07:00:00.00000000[-07:00:00.00000000]",
  "2021-08-19T17:30-07:00:00.000000001[-07:00:00.000000001]",
  "2021-08-19T17:30-07:00:00.000000000[-07:00:00.000000000]",

  "2021-08-19T17:30-07:00:01[-070001]",
  "2021-08-19T17:30-07:00:00[-070000]",
  "2021-08-19T17:30-07:00:00.1[-070000.1]",
  "2021-08-19T17:30-07:00:00.0[-070000.0]",
  "2021-08-19T17:30-07:00:00.01[-070000.01]",
  "2021-08-19T17:30-07:00:00.00[-070000.00]",
  "2021-08-19T17:30-07:00:00.001[-070000.001]",
  "2021-08-19T17:30-07:00:00.000[-070000.000]",
  "2021-08-19T17:30-07:00:00.0001[-070000.0001]",
  "2021-08-19T17:30-07:00:00.0000[-070000.0000]",
  "2021-08-19T17:30-07:00:00.00001[-070000.00001]",
  "2021-08-19T17:30-07:00:00.00000[-070000.00000]",
  "2021-08-19T17:30-07:00:00.000001[-070000.000001]",
  "2021-08-19T17:30-07:00:00.000000[-070000.000000]",
  "2021-08-19T17:30-07:00:00.0000001[-070000.0000001]",
  "2021-08-19T17:30-07:00:00.0000000[-070000.0000000]",
  "2021-08-19T17:30-07:00:00.00000001[-070000.00000001]",
  "2021-08-19T17:30-07:00:00.00000000[-070000.00000000]",
  "2021-08-19T17:30-07:00:00.000000001[-070000.000000001]",
  "2021-08-19T17:30-07:00:00.000000000[-070000.000000000]"
].forEach((str) => {
  assert.throws(
    RangeError,
    () => Temporal.Instant.from(str),
    `ISO strings cannot have sub-minute offsets in time zone annotations: ${str}`
  );
});

reportCompare(0, 0);