summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-10-12 02:23:17 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-23 15:48:45 +0200
commit3dc99af3dc7f736d1b7459cac1df4f0ea1ef8e40 (patch)
tree3160451f690f001e151aca615f4f35d03ba7bcfd /Userland/Libraries/LibJS/Runtime
parentd66bfcc3f4dd13f6ebb91c15b65e5abee75ead87 (diff)
downloadserenity-3dc99af3dc7f736d1b7459cac1df4f0ea1ef8e40.zip
LibJS: Make parse_temporal_duration use the new double parser
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
index 026354dc24..ae7bdf165e 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
@@ -1482,22 +1482,20 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String
auto seconds_part = parse_result->duration_whole_seconds;
auto f_seconds_part = parse_result->duration_seconds_fraction;
- // FIXME: I can has StringView::to<double>()?
-
// 4. Let yearsMV be ! ToIntegerOrInfinity(CodePointsToString(years)).
- auto years = strtod(String { years_part.value_or("0"sv) }.characters(), nullptr);
+ auto years = years_part.value_or("0"sv).to_double().release_value();
// 5. Let monthsMV be ! ToIntegerOrInfinity(CodePointsToString(months)).
- auto months = strtod(String { months_part.value_or("0"sv) }.characters(), nullptr);
+ auto months = months_part.value_or("0"sv).to_double().release_value();
// 6. Let weeksMV be ! ToIntegerOrInfinity(CodePointsToString(weeks)).
- auto weeks = strtod(String { weeks_part.value_or("0"sv) }.characters(), nullptr);
+ auto weeks = weeks_part.value_or("0"sv).to_double().release_value();
// 7. Let daysMV be ! ToIntegerOrInfinity(CodePointsToString(days)).
- auto days = strtod(String { days_part.value_or("0"sv) }.characters(), nullptr);
+ auto days = days_part.value_or("0"sv).to_double().release_value();
// 8. Let hoursMV be ! ToIntegerOrInfinity(CodePointsToString(hours)).
- auto hours = strtod(String { hours_part.value_or("0"sv) }.characters(), nullptr);
+ auto hours = hours_part.value_or("0"sv).to_double().release_value();
double minutes;
@@ -1514,12 +1512,12 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String
auto f_hours_scale = (double)f_hours_digits.length();
// d. Let minutesMV be ! ToIntegerOrInfinity(fHoursDigits) / 10^fHoursScale × 60.
- minutes = strtod(String { f_hours_digits }.characters(), nullptr) / pow(10, f_hours_scale) * 60;
+ minutes = f_hours_digits.to_double().release_value() / pow(10., f_hours_scale) * 60;
}
// 10. Else,
else {
// a. Let minutesMV be ! ToIntegerOrInfinity(CodePointsToString(minutes)).
- minutes = strtod(String { minutes_part.value_or("0"sv) }.characters(), nullptr);
+ minutes = minutes_part.value_or("0"sv).to_double().release_value();
}
double seconds;
@@ -1537,12 +1535,12 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String
auto f_minutes_scale = (double)f_minutes_digits.length();
// d. Let secondsMV be ! ToIntegerOrInfinity(fMinutesDigits) / 10^fMinutesScale × 60.
- seconds = strtod(String { f_minutes_digits }.characters(), nullptr) / pow(10, f_minutes_scale) * 60;
+ seconds = f_minutes_digits.to_double().release_value() / pow(10, f_minutes_scale) * 60;
}
// 12. Else if seconds is not empty, then
else if (seconds_part.has_value()) {
// a. Let secondsMV be ! ToIntegerOrInfinity(CodePointsToString(seconds)).
- seconds = strtod(String { *seconds_part }.characters(), nullptr);
+ seconds = seconds_part.value_or("0"sv).to_double().release_value();
}
// 13. Else,
else {
@@ -1561,7 +1559,7 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String
auto f_seconds_scale = (double)f_seconds_digits.length();
// c. Let millisecondsMV be ! ToIntegerOrInfinity(fSecondsDigits) / 10^fSecondsScale × 1000.
- milliseconds = strtod(String { f_seconds_digits }.characters(), nullptr) / pow(10, f_seconds_scale) * 1000;
+ milliseconds = f_seconds_digits.to_double().release_value() / pow(10, f_seconds_scale) * 1000;
}
// 15. Else,
else {