1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +00:00

LibJS: Replace magic nanosecond numbers with constants

This is an editorial change in the Temporal spec.

See: 3fdbfda
This commit is contained in:
Linus Groh 2022-05-06 19:28:56 +02:00
parent 3729a910f6
commit c6f7214a60
9 changed files with 45 additions and 36 deletions

View file

@ -6,6 +6,7 @@
*/
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Date.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
@ -531,9 +532,9 @@ DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 micro
// 3. If unit is "day", then
if (unit == "day"sv) {
// a. If dayLengthNs is not present, set dayLengthNs to 8.64 × 10^13.
// a. If dayLengthNs is not present, set dayLengthNs to nsPerDay.
if (!day_length_ns.has_value())
day_length_ns = 86400000000000;
day_length_ns = ns_per_day;
// b. Let quantity be (((((hour × 60 + minute) × 60 + second) × 1000 + millisecond) × 1000 + microsecond) × 1000 + nanosecond) / dayLengthNs.
quantity = (((((hour * 60 + minute) * 60 + second) * 1000 + millisecond) * 1000 + microsecond) * 1000 + nanosecond) / *day_length_ns;