mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +00:00
LibJS: Use StringViews in Round{NumberToIncrement, TemporalInstant}
This commit is contained in:
parent
4b5aa2102c
commit
456938add0
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