diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /js/src/builtin/temporal/TemporalUnit.h | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/builtin/temporal/TemporalUnit.h')
-rw-r--r-- | js/src/builtin/temporal/TemporalUnit.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/builtin/temporal/TemporalUnit.h b/js/src/builtin/temporal/TemporalUnit.h index 3c8801cb85..0294c1062d 100644 --- a/js/src/builtin/temporal/TemporalUnit.h +++ b/js/src/builtin/temporal/TemporalUnit.h @@ -52,6 +52,31 @@ constexpr int64_t ToNanoseconds(TemporalUnit unit) { MOZ_CRASH("Unexpected temporal unit"); } +constexpr int64_t ToMicroseconds(TemporalUnit unit) { + switch (unit) { + case TemporalUnit::Day: + return 86'400'000'000; + case TemporalUnit::Hour: + return 3'600'000'000; + case TemporalUnit::Minute: + return 60'000'000; + case TemporalUnit::Second: + return 1'000'000; + case TemporalUnit::Millisecond: + return 1'000; + case TemporalUnit::Microsecond: + return 1; + + case TemporalUnit::Auto: + case TemporalUnit::Year: + case TemporalUnit::Month: + case TemporalUnit::Week: + case TemporalUnit::Nanosecond: + break; + } + MOZ_CRASH("Unexpected temporal unit"); +} + constexpr int64_t ToMilliseconds(TemporalUnit unit) { switch (unit) { case TemporalUnit::Day: @@ -76,6 +101,29 @@ constexpr int64_t ToMilliseconds(TemporalUnit unit) { MOZ_CRASH("Unexpected temporal unit"); } +constexpr int64_t ToSeconds(TemporalUnit unit) { + switch (unit) { + case TemporalUnit::Day: + return 86'400; + case TemporalUnit::Hour: + return 3'600; + case TemporalUnit::Minute: + return 60; + case TemporalUnit::Second: + return 1; + + case TemporalUnit::Auto: + case TemporalUnit::Year: + case TemporalUnit::Month: + case TemporalUnit::Week: + case TemporalUnit::Millisecond: + case TemporalUnit::Microsecond: + case TemporalUnit::Nanosecond: + break; + } + MOZ_CRASH("Unexpected temporal unit"); +} + constexpr int64_t UnitsPerDay(TemporalUnit unit) { switch (unit) { case TemporalUnit::Day: |