Debian Codegraph @

js/src/tests/test262/intl402/Temporal/Duration/compare/relativeto-sub-minute-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) 2021 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.duration.compare
7 description: relativeTo string accepts an inexact UTC offset rounded to hours and minutes
8 features: [Temporal]
9 ---*/
10
11 const duration1 = new Temporal.Duration(0, 0, 0, 31);
12 const duration2 = new Temporal.Duration(0, 1);
13
14 let result;
15 let relativeTo;
16
17 const action = (relativeTo) => Temporal.Duration.compare(duration1, duration2, { relativeTo });
18
19 relativeTo = "1970-01-01T00:00:00-00:45[Africa/Monrovia]";
20 result = action(relativeTo);
21 assert.sameValue(result, 0, "rounded HH:MM is accepted in string offset");
22
23 relativeTo = "1970-01-01T00:00:00-00:44:30[Africa/Monrovia]";
24 result = action(relativeTo);
25 assert.sameValue(result, 0, "unrounded HH:MM:SS is accepted in string offset");
26
27 relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone: "Africa/Monrovia" };
28 assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag");
29
30 reportCompare(0, 0);