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.
This commit is contained in:
Linus Groh 2022-03-16 19:19:20 +00:00
parent 356fa2dca1
commit 619794dfa7
Notes: sideshowbarker 2024-07-17 17:16:30 +09:00

View File

@ -296,7 +296,10 @@ ThrowCompletionOr<double> 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<i32>();
}