From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../prototype/total/dst-rounding-result.js | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js (limited to 'js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js') diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js new file mode 100644 index 0000000000..b2b4daf2de --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js @@ -0,0 +1,40 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.total +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +// Based on a test case by Adam Shaw + +{ + // Date part of duration lands on skipped DST hour, causing disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15, 12); + const relativeTo = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + timeZone); /* = 2000-02-18T02-08 in local time */ + + assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, + "1 month 15 days 12 hours should be exactly 1.5 months"); +} + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15); + const relativeTo = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + timeZone); /* = 2000-03-02T02-08 in local time */ + + assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, + "1 month 15 days should be exactly 1.5 months"); +} + +reportCompare(0, 0); -- cgit v1.2.3