1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

LibJS: Change nanoseconds_to_days() result from a JS to Crypto BigInt

Similar to the preceding commit(s).
This commit is contained in:
Linus Groh 2022-03-18 23:11:33 +00:00
parent 360c65e92b
commit 039cb9f189
3 changed files with 7 additions and 8 deletions

View file

@ -456,7 +456,7 @@ ThrowCompletionOr<TimeDurationRecord> balance_duration(GlobalObject& global_obje
days = result.days;
// c. Set nanoseconds to result.[[Nanoseconds]].
total_nanoseconds_bigint = result.nanoseconds.cell();
total_nanoseconds_bigint = js_bigint(vm, move(result.nanoseconds));
}
// 5. Else,
else {
@ -1174,7 +1174,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d
auto result = TRY(nanoseconds_to_days(global_object, *js_bigint(vm, nanoseconds_bigint), intermediate));
// e. Set days to days + result.[[Days]] + result.[[Nanoseconds]] / result.[[DayLength]].
auto nanoseconds_division_result = result.nanoseconds->big_integer().divided_by(Crypto::UnsignedBigInteger::create_from((u64)result.day_length));
auto nanoseconds_division_result = result.nanoseconds.divided_by(Crypto::UnsignedBigInteger::create_from((u64)result.day_length));
days += result.days + nanoseconds_division_result.quotient.to_double() + nanoseconds_division_result.remainder.to_double() / result.day_length;
// f. Set hours, minutes, seconds, milliseconds, microseconds, and nanoseconds to 0.