diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-10-14 09:47:17 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-15 18:05:02 +0200 |
commit | 1a84dbcb07c2edec252b414e273107d50fe2deff (patch) | |
tree | d2f65a81a6a7f9135a4f9f1a2d9b898e4fb0e8a0 /Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp | |
parent | 4fbec2e8b3141ca5b895d7c9bb17f8b0cf22bca2 (diff) | |
download | serenity-1a84dbcb07c2edec252b414e273107d50fe2deff.zip |
LibJS: Replace GetEpochFromISOParts with GetUTCEpochNanoseconds
This is an editorial change in the Temporal spec. See:
https://github.com/tc39/proposal-temporal/commit/1b051cc
Note that since Date's implementation of this AO uses Crypto bigints
rather than allocating JS bigints, this change has the fallout of
removing some unused VM parameters and adding an overload of the
IsValidEpochNanoseconds AO for use without a JS::BigInt.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index 7acba1931c..1c695e6312 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -57,19 +57,18 @@ ThrowCompletionOr<BigInt const*> interpret_iso_date_time_offset(VM& vm, i32 year // 4. If offsetBehaviour is exact or offsetOption is "use", then if (offset_behavior == OffsetBehavior::Exact || offset_option == "use"sv) { - // a. Let epochNanoseconds be GetEpochFromISOParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond). - auto* epoch_nanoseconds = get_epoch_from_iso_parts(vm, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond); + // a. Let epochNanoseconds be GetUTCEpochNanoseconds(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond). + auto epoch_nanoseconds = get_utc_epoch_nanoseconds(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond); // b. Set epochNanoseconds to epochNanoseconds - ℤ(offsetNanoseconds). - auto offset_nanoseconds_bigint = Crypto::SignedBigInteger { offset_nanoseconds }; - epoch_nanoseconds = js_bigint(vm, epoch_nanoseconds->big_integer().minus(offset_nanoseconds_bigint)); + epoch_nanoseconds = epoch_nanoseconds.minus(Crypto::SignedBigInteger { offset_nanoseconds }); // c. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception. - if (!is_valid_epoch_nanoseconds(*epoch_nanoseconds)) + if (!is_valid_epoch_nanoseconds(epoch_nanoseconds)) return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // d. Return epochNanoseconds. - return epoch_nanoseconds; + return js_bigint(vm, move(epoch_nanoseconds)); } // 5. Assert: offsetBehaviour is option. |