1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +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

@ -39,8 +39,8 @@ bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds)
{
// 1. Assert: Type(epochNanoseconds) is BigInt.
// 2. If epochNanoseconds < -86400 × 10^17 or epochNanoseconds > 86400 × 10^17, then
if (epoch_nanoseconds.big_integer() < INSTANT_NANOSECONDS_MIN || epoch_nanoseconds.big_integer() > INSTANT_NANOSECONDS_MAX) {
// 2. If (epochNanoseconds) < nsMinInstant or (epochNanoseconds) > nsMaxInstant, then
if (epoch_nanoseconds.big_integer() < ns_min_instant || epoch_nanoseconds.big_integer() > ns_max_instant) {
// a. Return false.
return false;
}
@ -119,7 +119,7 @@ ThrowCompletionOr<BigInt*> parse_temporal_instant(GlobalObject& global_object, S
auto* utc = get_epoch_from_iso_parts(global_object, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond);
// 6. If (utc) < -8.64 × 10^21 or (utc) > 8.64 × 10^21, then
if (utc->big_integer() < INSTANT_NANOSECONDS_MIN || utc->big_integer() > INSTANT_NANOSECONDS_MAX) {
if (utc->big_integer() < ns_min_instant || utc->big_integer() > ns_max_instant) {
// a. Throw a RangeError exception.
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
}