From 46c3406008c6c1ba114865368d839955700bfcc9 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 5 Dec 2024 10:01:21 -0500 Subject: [PATCH] LibJS: Swap arguments in invocation to AddTimeDurationToEpochNanoseconds This is an editorial change in the Temporal proposal. See: https://github.com/tc39/proposal-temporal/commit/630b043 This also changes the second argument of this AO to not use the alias of TimeDuration, as that should not be used to refer to epoch nanoseconds. This was missed in commit 2d9405e5d70ff16961c5eb0e9c437ef6a295a9b4. --- Libraries/LibJS/Runtime/Temporal/Duration.cpp | 2 +- Libraries/LibJS/Runtime/Temporal/Duration.h | 2 +- Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Libraries/LibJS/Runtime/Temporal/Duration.cpp index 3e667886616..0e3eb7292f7 100644 --- a/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -734,7 +734,7 @@ ThrowCompletionOr add_24_hour_days_to_time_duration(VM& vm, TimeDu } // 7.5.24 AddTimeDurationToEpochNanoseconds ( d, epochNs ), https://tc39.es/proposal-temporal/#sec-temporal-addtimedurationtoepochnanoseconds -TimeDuration add_time_duration_to_epoch_nanoseconds(TimeDuration const& duration, TimeDuration const& epoch_nanoseconds) +Crypto::SignedBigInteger add_time_duration_to_epoch_nanoseconds(TimeDuration const& duration, Crypto::SignedBigInteger const& epoch_nanoseconds) { // 1. Return epochNs + ℤ(d). return epoch_nanoseconds.plus(duration); diff --git a/Libraries/LibJS/Runtime/Temporal/Duration.h b/Libraries/LibJS/Runtime/Temporal/Duration.h index c0c6507bf32..8cf4b14c11e 100644 --- a/Libraries/LibJS/Runtime/Temporal/Duration.h +++ b/Libraries/LibJS/Runtime/Temporal/Duration.h @@ -129,7 +129,7 @@ GC::Ref create_negated_temporal_duration(VM&, Duration const&); TimeDuration time_duration_from_components(double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds); ThrowCompletionOr add_time_duration(VM&, TimeDuration const&, TimeDuration const&); ThrowCompletionOr add_24_hour_days_to_time_duration(VM&, TimeDuration const&, double days); -TimeDuration add_time_duration_to_epoch_nanoseconds(TimeDuration const& duration, TimeDuration const& epoch_nanoseconds); +Crypto::SignedBigInteger add_time_duration_to_epoch_nanoseconds(TimeDuration const& duration, Crypto::SignedBigInteger const& epoch_nanoseconds); i8 compare_time_duration(TimeDuration const&, TimeDuration const&); TimeDuration time_duration_from_epoch_nanoseconds_difference(Crypto::SignedBigInteger const&, Crypto::SignedBigInteger const&); ThrowCompletionOr round_time_duration_to_increment(VM&, TimeDuration const&, Crypto::UnsignedBigInteger const& increment, RoundingMode); diff --git a/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index fe480a1a652..f9d986cfc9a 100644 --- a/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -703,8 +703,8 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::round) // i. Let roundedDayNs be ! RoundTimeDurationToIncrement(dayProgressNs, dayLengthNs, roundingMode). auto rounded_day_nanoseconds = MUST(round_time_duration_to_increment(vm, day_progress_nanoseconds, day_length_nanoseconds.unsigned_value(), rounding_mode)); - // j. Let epochNanoseconds be AddTimeDurationToEpochNanoseconds(startNs, roundedDayNs). - epoch_nanoseconds = add_time_duration_to_epoch_nanoseconds(start_nanoseconds, rounded_day_nanoseconds); + // j. Let epochNanoseconds be AddTimeDurationToEpochNanoseconds(roundedDayNs, startNs). + epoch_nanoseconds = add_time_duration_to_epoch_nanoseconds(rounded_day_nanoseconds, start_nanoseconds); } // 19. Else, else {