Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/offset-overrides-critical-flag.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.zoneddatetime.from
7 description: >
8 The offset option always overrides the critical flag in a time zone annotation
9 features: [Temporal]
10 ---*/
11
12 const useResult = Temporal.ZonedDateTime.from("2022-10-07T18:37-07:00[!UTC]", { offset: "use" });
13 assert.sameValue(
14 useResult.epochNanoseconds,
15 1665193020000000000n,
16 "exact time is unchanged with offset = use, despite critical flag"
17 );
18
19 const ignoreResult = Temporal.ZonedDateTime.from("2022-10-07T18:37-07:00[!UTC]", { offset: "ignore" });
20 assert.sameValue(
21 ignoreResult.epochNanoseconds,
22 1665167820000000000n,
23 "wall time is unchanged with offset = ignore, despite critical flag"
24 );
25
26 const preferResult = Temporal.ZonedDateTime.from("2022-10-07T18:37-07:00[!UTC]", { offset: "prefer" });
27 assert.sameValue(
28 useResult.epochNanoseconds,
29 1665193020000000000n,
30 "offset is recalculated with offset = prefer, despite critical flag"
31 );
32
33 reportCompare(0, 0);