mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibJS: Restore some Temporal numeric constants
And add few ad-hoc constants for convenience.
This commit is contained in:
parent
e4e05837e1
commit
eca378a7a3
Notes:
github-actions[bot]
2024-11-21 00:06:28 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/eca378a7a31 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2431 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/shannonbooth ✅
3 changed files with 77 additions and 0 deletions
|
@ -206,6 +206,7 @@ set(SOURCES
|
||||||
Runtime/SymbolPrototype.cpp
|
Runtime/SymbolPrototype.cpp
|
||||||
Runtime/Temporal/AbstractOperations.cpp
|
Runtime/Temporal/AbstractOperations.cpp
|
||||||
Runtime/Temporal/Duration.cpp
|
Runtime/Temporal/Duration.cpp
|
||||||
|
Runtime/Temporal/Instant.cpp
|
||||||
Runtime/Temporal/Temporal.cpp
|
Runtime/Temporal/Temporal.cpp
|
||||||
Runtime/TypedArray.cpp
|
Runtime/TypedArray.cpp
|
||||||
Runtime/TypedArrayConstructor.cpp
|
Runtime/TypedArrayConstructor.cpp
|
||||||
|
|
37
Libraries/LibJS/Runtime/Temporal/Instant.cpp
Normal file
37
Libraries/LibJS/Runtime/Temporal/Instant.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||||
|
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
||||||
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Temporal/Instant.h>
|
||||||
|
|
||||||
|
namespace JS::Temporal {
|
||||||
|
|
||||||
|
// nsMaxInstant = 10**8 × nsPerDay = 8.64 × 10**21
|
||||||
|
Crypto::SignedBigInteger const NANOSECONDS_MAX_INSTANT = "8640000000000000000000"_sbigint;
|
||||||
|
|
||||||
|
// nsMinInstant = -nsMaxInstant = -8.64 × 10**21
|
||||||
|
Crypto::SignedBigInteger const NANOSECONDS_MIN_INSTANT = "-8640000000000000000000"_sbigint;
|
||||||
|
|
||||||
|
// nsPerDay = 10**6 × ℝ(msPerDay) = 8.64 × 10**13
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_DAY = 86400000000000_bigint;
|
||||||
|
|
||||||
|
// Non-standard:
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_HOUR = 3600000000000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_MINUTE = 60000000000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_SECOND = 1000000000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_MILLISECOND = 1000000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_MICROSECOND = 1000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const NANOSECONDS_PER_NANOSECOND = 1_bigint;
|
||||||
|
|
||||||
|
Crypto::UnsignedBigInteger const MICROSECONDS_PER_MILLISECOND = 1000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const MILLISECONDS_PER_SECOND = 1000_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const SECONDS_PER_MINUTE = 60_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const MINUTES_PER_HOUR = 60_bigint;
|
||||||
|
Crypto::UnsignedBigInteger const HOURS_PER_DAY = 24_bigint;
|
||||||
|
|
||||||
|
}
|
39
Libraries/LibJS/Runtime/Temporal/Instant.h
Normal file
39
Libraries/LibJS/Runtime/Temporal/Instant.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||||
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||||
|
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
|
||||||
|
|
||||||
|
namespace JS::Temporal {
|
||||||
|
|
||||||
|
// https://tc39.es/proposal-temporal/#eqn-nsMaxInstant
|
||||||
|
extern Crypto::SignedBigInteger const NANOSECONDS_MAX_INSTANT;
|
||||||
|
|
||||||
|
// https://tc39.es/proposal-temporal/#eqn-nsMinInstant
|
||||||
|
extern Crypto::SignedBigInteger const NANOSECONDS_MIN_INSTANT;
|
||||||
|
|
||||||
|
// https://tc39.es/proposal-temporal/#eqn-nsPerDay
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_DAY;
|
||||||
|
|
||||||
|
// Non-standard:
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_HOUR;
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_MINUTE;
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_SECOND;
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_MILLISECOND;
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_MICROSECOND;
|
||||||
|
extern Crypto::UnsignedBigInteger const NANOSECONDS_PER_NANOSECOND;
|
||||||
|
|
||||||
|
extern Crypto::UnsignedBigInteger const MICROSECONDS_PER_MILLISECOND;
|
||||||
|
extern Crypto::UnsignedBigInteger const MILLISECONDS_PER_SECOND;
|
||||||
|
extern Crypto::UnsignedBigInteger const SECONDS_PER_MINUTE;
|
||||||
|
extern Crypto::UnsignedBigInteger const MINUTES_PER_HOUR;
|
||||||
|
extern Crypto::UnsignedBigInteger const HOURS_PER_DAY;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue