diff options
author | Linus Groh <mail@linusgroh.de> | 2022-06-23 19:37:25 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-06-24 22:12:03 +0100 |
commit | 9c31fee4b5658d8f3deb50997016aee1fee71419 (patch) | |
tree | be8941f032ee615196933c6a9c5fa49bd235c835 /Userland/Libraries/LibJS/Runtime/Temporal | |
parent | 0ff6260afbec3317ad390edef09c688cf34b6415 (diff) | |
download | serenity-9c31fee4b5658d8f3deb50997016aee1fee71419.zip |
LibJS: Remove unnecessary modulo operation in GetISOPartsFromEpoch
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/fc3f80d
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp index 4248f74ef8..74be2f637e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp @@ -136,13 +136,16 @@ ISODateTime get_iso_parts_from_epoch(GlobalObject& global_object, Crypto::Signed // 10. Let millisecond be ℝ(! msFromTime(epochMilliseconds)). auto millisecond = ms_from_time(epoch_milliseconds); - // 11. Let microsecond be floor(remainderNs / 1000) modulo 1000. - auto microsecond = modulo(floor(remainder_ns / 1000), 1000); + // 11. Let microsecond be floor(remainderNs / 1000). + auto microsecond = floor(remainder_ns / 1000); - // 12. Let nanosecond be remainderNs modulo 1000. + // 12. Assert: microsecond < 1000. + VERIFY(microsecond < 1000); + + // 13. Let nanosecond be remainderNs modulo 1000. auto nanosecond = modulo(remainder_ns, 1000); - // 13. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }. + // 14. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }. return { .year = year, .month = month, .day = day, .hour = hour, .minute = minute, .second = second, .millisecond = millisecond, .microsecond = static_cast<u16>(microsecond), .nanosecond = static_cast<u16>(nanosecond) }; } |