mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibJS: Use StringViews in Round{NumberToIncrement, TemporalInstant}
This commit is contained in:
parent
4b5aa2102c
commit
456938add0
Notes:
sideshowbarker
2024-07-18 04:34:03 +09:00
Author: https://github.com/IdanHo
Commit: 456938add0
Pull-request: https://github.com/SerenityOS/serenity/pull/9859
Reviewed-by: https://github.com/linusg ✅
4 changed files with 14 additions and 14 deletions
|
@ -204,40 +204,40 @@ BigInt* difference_instant(GlobalObject& global_object, BigInt const& nanosecond
|
|||
}
|
||||
|
||||
// 8.5.8 RoundTemporalInstant ( ns, increment, unit, roundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-roundtemporalinstant
|
||||
BigInt* round_temporal_instant(GlobalObject& global_object, BigInt const& nanoseconds, u64 increment, String const& unit, String const& rounding_mode)
|
||||
BigInt* round_temporal_instant(GlobalObject& global_object, BigInt const& nanoseconds, u64 increment, StringView unit, StringView rounding_mode)
|
||||
{
|
||||
// 1. Assert: Type(ns) is BigInt.
|
||||
|
||||
u64 increment_nanoseconds;
|
||||
// 2. If unit is "hour", then
|
||||
if (unit == "hour") {
|
||||
if (unit == "hour"sv) {
|
||||
// a. Let incrementNs be increment × 3.6 × 10^12.
|
||||
increment_nanoseconds = increment * 3600000000000;
|
||||
}
|
||||
// 3. Else if unit is "minute", then
|
||||
else if (unit == "minute") {
|
||||
else if (unit == "minute"sv) {
|
||||
// a. Let incrementNs be increment × 6 × 10^10.
|
||||
increment_nanoseconds = increment * 60000000000;
|
||||
}
|
||||
// 4. Else if unit is "second", then
|
||||
else if (unit == "second") {
|
||||
else if (unit == "second"sv) {
|
||||
// a. Let incrementNs be increment × 10^9.
|
||||
increment_nanoseconds = increment * 1000000000;
|
||||
}
|
||||
// 5. Else if unit is "millisecond", then
|
||||
else if (unit == "millisecond") {
|
||||
else if (unit == "millisecond"sv) {
|
||||
// a. Let incrementNs be increment × 10^6.
|
||||
increment_nanoseconds = increment * 1000000;
|
||||
}
|
||||
// 6. Else if unit is "microsecond", then
|
||||
else if (unit == "microsecond") {
|
||||
else if (unit == "microsecond"sv) {
|
||||
// a. Let incrementNs be increment × 10^3.
|
||||
increment_nanoseconds = increment * 1000;
|
||||
}
|
||||
// 7. Else,
|
||||
else {
|
||||
// a. Assert: unit is "nanosecond".
|
||||
VERIFY(unit == "nanosecond");
|
||||
VERIFY(unit == "nanosecond"sv);
|
||||
|
||||
// b. Let incrementNs be increment.
|
||||
increment_nanoseconds = increment;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue