Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / Duration / prototype / total / dst-rounding-result.js
blobb2b4daf2dedb0f1cc4899b754af30a35f515eae1
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2024 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-temporal.duration.prototype.total
6 description: >
7     Rounding the resulting duration takes the time zone's UTC offset shifts
8     into account
9 includes: [temporalHelpers.js]
10 features: [Temporal]
11 ---*/
13 const timeZone = TemporalHelpers.springForwardFallBackTimeZone();
15 // Based on a test case by Adam Shaw
18   // Date part of duration lands on skipped DST hour, causing disambiguation
19   const duration = new Temporal.Duration(0, 1, 0, 15, 12);
20   const relativeTo = new Temporal.ZonedDateTime(
21     950868000_000_000_000n /* = 2000-02-18T10Z */,
22     timeZone); /* = 2000-02-18T02-08 in local time */
24   assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5,
25     "1 month 15 days 12 hours should be exactly 1.5 months");
29   // Month-only part of duration lands on skipped DST hour, should not cause
30   // disambiguation
31   const duration = new Temporal.Duration(0, 1, 0, 15);
32   const relativeTo = new Temporal.ZonedDateTime(
33     951991200_000_000_000n /* = 2000-03-02T10Z */,
34     timeZone); /* = 2000-03-02T02-08 in local time */
36   assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5,
37     "1 month 15 days should be exactly 1.5 months");
40 reportCompare(0, 0);