summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-12-18 20:57:40 +0000
committerLinus Groh <mail@linusgroh.de>2021-12-18 22:32:39 +0000
commitacce65b52c0ac560a3cc95b2cb8314143d0cad92 (patch)
tree52fb98d8d77bdf3814448acf9824c5e4d775dbb1
parent6d5e95d6216d762ed064c36c1f734801d25b1f83 (diff)
downloadserenity-acce65b52c0ac560a3cc95b2cb8314143d0cad92.zip
LibJS: Fix fractionalSecondDigits behavior in Duration.proto.toString()
This is a normative change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/3ee771e
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
index 002deae7b7..78dc953a64 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp
@@ -1778,8 +1778,8 @@ String temporal_duration_to_string(double years, double months, double weeks, do
time_part.append('M');
}
- // 21. If any of seconds, milliseconds, microseconds, and nanoseconds are not 0; or years, months, weeks, days, hours, and minutes are all 0, then
- if ((seconds != 0 || milliseconds != 0 || microseconds != 0 || nanoseconds != 0) || (years == 0 && months == 0 && weeks == 0 && days == 0 && hours == 0 && minutes == 0)) {
+ // 21. If any of seconds, milliseconds, microseconds, and nanoseconds are not 0; or years, months, weeks, days, hours, and minutes are all 0; or precision is not "auto"; then
+ if ((seconds != 0 || milliseconds != 0 || microseconds != 0 || nanoseconds != 0) || (years == 0 && months == 0 && weeks == 0 && days == 0 && hours == 0 && minutes == 0) || (precision.has<StringView>() && precision.get<StringView>() != "auto"sv)) {
// a. Let fraction be abs(milliseconds) × 10^6 + abs(microseconds) × 10^3 + abs(nanoseconds).
auto fraction = fabs(milliseconds) * 1'000'000 + fabs(microseconds) * 1'000 + fabs(nanoseconds);