diff options
author | Linus Groh <mail@linusgroh.de> | 2021-12-21 21:22:38 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-12-22 11:27:31 +0100 |
commit | 9c209b80793b7717ba5a3973722e0b5941696cfd (patch) | |
tree | ef7f0c9e78db2198bf376613405515f2d5bf7eaa /Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp | |
parent | 1ec917aa23dbc0e3d95e0dfe5f279971789cfcb8 (diff) | |
download | serenity-9c209b80793b7717ba5a3973722e0b5941696cfd.zip |
LibJS: Support modulo(x, y) with different types
It's a bit annoying having to add '.0' to y given that it's an integral
number in most cases.
This turns the single template parameter T into T and U to permit that.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp index 7224392ebc..932e531afd 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp @@ -281,37 +281,37 @@ DaysAndTime balance_time(double hour, double minute, double second, double milli microsecond += floor(nanosecond / 1000); // 3. Set nanosecond to nanosecond modulo 1000. - nanosecond = modulo(nanosecond, 1000.0); + nanosecond = modulo(nanosecond, 1000); // 4. Set millisecond to millisecond + floor(microsecond / 1000). millisecond += floor(microsecond / 1000); // 5. Set microsecond to microsecond modulo 1000. - microsecond = modulo(microsecond, 1000.0); + microsecond = modulo(microsecond, 1000); // 6. Set second to second + floor(millisecond / 1000). second += floor(millisecond / 1000); // 7. Set millisecond to millisecond modulo 1000. - millisecond = modulo(millisecond, 1000.0); + millisecond = modulo(millisecond, 1000); // 8. Set minute to minute + floor(second / 60). minute += floor(second / 60); // 9. Set second to second modulo 60. - second = modulo(second, 60.0); + second = modulo(second, 60); // 10. Set hour to hour + floor(minute / 60). hour += floor(minute / 60); // 11. Set minute to minute modulo 60. - minute = modulo(minute, 60.0); + minute = modulo(minute, 60); // 12. Let days be floor(hour / 24). auto days = floor(hour / 24); // 13. Set hour to hour modulo 24. - hour = modulo(hour, 24.0); + hour = modulo(hour, 24); // 14. Return the Record { [[Days]]: days, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }. return DaysAndTime { |