From 619794dfa70cecbd87b388e4127c77cdd483b7a0 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 16 Mar 2022 19:19:20 +0000 Subject: [PATCH] LibJS: Fix fraction substring in ParseTimeZoneOffsetString This is a normative change in the Temporal spec. See: - https://github.com/tc39/proposal-temporal/commit/97d553c - https://github.com/tc39/proposal-temporal/commit/d53af7f Note that we already implemented this correctly, so the only change is updating the spec comment. --- Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp index 866211a39e..4cd8a8d8e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp @@ -296,7 +296,10 @@ ThrowCompletionOr parse_time_zone_offset_string(GlobalObject& global_obj if (fraction_part.has_value()) { // a. Set fraction to the string-concatenation of the previous value of fraction and the string "000000000". auto fraction = String::formatted("{}000000000", *fraction_part); - // b. Let nanoseconds be the String value equal to the substring of fraction consisting of the code units with indices 0 (inclusive) through 9 (exclusive). + + // b. Let nanoseconds be the String value equal to the substring of fraction from 1 to 10. + // NOTE: parse_time_zone_numeric_utc_offset_syntax(), which we use to capture TimeZoneUTCOffsetFraction, doesn't include the decimal separator. + // c. Set nanoseconds to ! ToIntegerOrInfinity(nanoseconds). nanoseconds = *fraction.substring(0, 9).to_int(); }