From 7aee254708cd9cf9dc790776df42feb2eb598df4 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 26 Nov 2024 12:36:32 -0500 Subject: [PATCH] LibJS: Use correct epoch offset in InterpretISODateTimeOffset --- Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp | 2 +- .../Temporal/Duration/Duration.prototype.total.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index 531962c09d7..c8c6be063d6 100644 --- a/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -114,7 +114,7 @@ ThrowCompletionOr interpret_iso_date_time_offset(VM& v auto rounded_candidate_nanoseconds = round_number_to_increment(candidate_offset, NANOSECONDS_PER_MINUTE, RoundingMode::HalfExpand); // ii. If roundedCandidateNanoseconds = offsetNanoseconds, then - if (candidate_offset.compare_to_double(offset_nanoseconds) == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt) { + if (rounded_candidate_nanoseconds.compare_to_double(offset_nanoseconds) == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt) { // 1. Return candidate. return move(candidate); } diff --git a/Libraries/LibJS/Tests/builtins/Temporal/Duration/Duration.prototype.total.js b/Libraries/LibJS/Tests/builtins/Temporal/Duration/Duration.prototype.total.js index 42a4e7cebb5..2190d40bede 100644 --- a/Libraries/LibJS/Tests/builtins/Temporal/Duration/Duration.prototype.total.js +++ b/Libraries/LibJS/Tests/builtins/Temporal/Duration/Duration.prototype.total.js @@ -39,6 +39,16 @@ describe("correct behavior", () => { expect(result).toBe(1); }); }); + + test("match minutes", () => { + const duration = new Temporal.Duration(1, 0, 0, 0, 24); + + const result = duration.total({ + unit: "days", + relativeTo: "1970-01-01T00:00:00-00:45[Africa/Monrovia]", + }); + expect(result).toBe(366); + }); }); describe("errors", () => {