LibJS: Change offset in ISODateTimeWithinLimits to actually 24h
This is a normative change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/1d61d6f
This commit is contained in:
parent
59df50a950
commit
8105d3f3d6
Notes:
sideshowbarker
2024-07-18 04:56:41 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/8105d3f3d68 Pull-request: https://github.com/SerenityOS/serenity/pull/9714 Reviewed-by: https://github.com/IdanHo ✅
1 changed files with 6 additions and 6 deletions
|
@ -70,10 +70,10 @@ BigInt* get_epoch_from_iso_parts(GlobalObject& global_object, i32 year, u8 month
|
|||
return js_bigint(vm, Crypto::SignedBigInteger::create_from(static_cast<i64>(ms.as_double())).multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 }).plus(Crypto::SignedBigInteger::create_from((i64)microsecond * 1000)).plus(Crypto::SignedBigInteger(nanosecond)));
|
||||
}
|
||||
|
||||
// -864 * 10^19 - 864 * 10^14
|
||||
const auto DATETIME_NANOSECONDS_MIN = "-8640086400000000000000"_sbigint;
|
||||
// +864 * 10^19 + 864 * 10^14
|
||||
const auto DATETIME_NANOSECONDS_MAX = "8640086400000000000000"_sbigint;
|
||||
// -864 * 10^19 - 864 * 10^11
|
||||
const auto DATETIME_NANOSECONDS_MIN = "-8640000086400000000000"_sbigint;
|
||||
// +864 * 10^19 + 864 * 10^11
|
||||
const auto DATETIME_NANOSECONDS_MAX = "8640000086400000000000"_sbigint;
|
||||
|
||||
// 5.5.2 ISODateTimeWithinLimits ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond ), https://tc39.es/proposal-temporal/#sec-temporal-isodatetimewithinlimits
|
||||
bool iso_date_time_within_limits(GlobalObject& global_object, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond)
|
||||
|
@ -83,13 +83,13 @@ bool iso_date_time_within_limits(GlobalObject& global_object, i32 year, u8 month
|
|||
// 2. Let ns be ! GetEpochFromISOParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond).
|
||||
auto ns = get_epoch_from_iso_parts(global_object, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond);
|
||||
|
||||
// 3. If ns ≤ -8.64 × 10^21 - 8.64 × 10^16, then
|
||||
// 3. If ns ≤ -8.64 × 10^21 - 8.64 × 10^13, then
|
||||
if (ns->big_integer() <= DATETIME_NANOSECONDS_MIN) {
|
||||
// a. Return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
// 4. If ns ≥ 8.64 × 10^21 + 8.64 × 10^16, then
|
||||
// 4. If ns ≥ 8.64 × 10^21 + 8.64 × 10^13, then
|
||||
if (ns->big_integer() >= DATETIME_NANOSECONDS_MAX) {
|
||||
// a. Return false.
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue