diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 049af3c7f1..66b8fcf3d6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -1007,7 +1007,7 @@ i64 round_number_to_increment(double x, u64 increment, StringView rounding_mode) } // 6. Else if roundingMode is "trunc", then else if (rounding_mode == "trunc"sv) { - // a. Let rounded be the integral part of quotient, removing any fractional digits. + // a. Let rounded be RoundTowardsZero(quotient). rounded = trunc(quotient); } // 7. Else, @@ -1056,7 +1056,7 @@ BigInt* round_number_to_increment(GlobalObject& global_object, BigInt const& x, } // 6. Else if roundingMode is "trunc", then else if (rounding_mode == "trunc"sv) { - // a. Let rounded be the integral part of quotient, removing any fractional digits. + // a. Let rounded be the RoundTowardsZero(quotient). // NOTE: This is a no-op } // 7. Else, diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index c698c09e65..cac81a34de 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -1590,19 +1590,19 @@ String temporal_duration_to_string(double years, double months, double weeks, do // 5. Let sign be ! DurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds). auto sign = duration_sign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds); - // 6. Set microseconds to microseconds + the integral part of nanoseconds / 1000. + // 6. Set microseconds to microseconds + RoundTowardsZero(nanoseconds / 1000). microseconds += trunc(nanoseconds / 1000); // 7. Set nanoseconds to remainder(nanoseconds, 1000). nanoseconds = fmod(nanoseconds, 1000); - // 8. Set milliseconds to milliseconds + the integral part of microseconds / 1000. + // 8. Set milliseconds to milliseconds + RoundTowardsZero(microseconds / 1000). milliseconds += trunc(microseconds / 1000); // 9. Set microseconds to remainder(microseconds, 1000). microseconds = fmod(microseconds, 1000); - // 10. Set seconds to seconds + the integral part of milliseconds / 1000. + // 10. Set seconds to seconds + RoundTowardsZero(milliseconds / 1000). seconds += trunc(milliseconds / 1000); // 11. Set milliseconds to remainder(milliseconds, 1000). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index cbe1c584fd..b601bc5042 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -453,7 +453,7 @@ ThrowCompletionOr nanoseconds_to_days(GlobalObject& glo // 4. If Type(relativeTo) is not Object or relativeTo does not have an [[InitializedTemporalZonedDateTime]] internal slot, then if (!relative_to_value.is_object() || !is(relative_to_value.as_object())) { - // a. Return the Record { [[Days]]: the integral part of nanoseconds / dayLengthNs, [[Nanoseconds]]: (abs(nanoseconds) modulo dayLengthNs) × sign, [[DayLength]]: dayLengthNs }. + // a. Return the Record { [[Days]]: RoundTowardsZero(nanoseconds / dayLengthNs), [[Nanoseconds]]: (abs(nanoseconds) modulo dayLengthNs) × sign, [[DayLength]]: dayLengthNs }. return NanosecondsToDaysResult { .days = nanoseconds.divided_by(day_length_ns).quotient.to_double(), .nanoseconds = Crypto::SignedBigInteger { nanoseconds.unsigned_value() }.divided_by(day_length_ns).remainder.multiplied_by(Crypto::SignedBigInteger { (i32)sign }),