mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
LibJS+LibLocale: Port Intl.NumberFormat to String
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 10:05:47 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0c2efa285a Pull-request: https://github.com/SerenityOS/serenity/pull/17132 Reviewed-by: https://github.com/linusg
@@ -624,7 +624,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
||||
auto formatted_value = MUST_OR_THROW_OOM(format_numeric(vm, *number_format3, Value(value)));
|
||||
|
||||
// iv. Append a new Record { [[Type]]: "fractionalSecond", [[Value]]: fv } as the last element of result.
|
||||
result.append({ "fractionalSecond"sv, TRY_OR_THROW_OOM(vm, String::from_deprecated_string(formatted_value)) });
|
||||
result.append({ "fractionalSecond"sv, move(formatted_value) });
|
||||
}
|
||||
|
||||
// d. Else if p is equal to "dayPeriod", then
|
||||
@@ -705,13 +705,13 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
||||
// viii. If f is "numeric", then
|
||||
case ::Locale::CalendarPatternStyle::Numeric:
|
||||
// 1. Let fv be FormatNumeric(nf, v).
|
||||
formatted_value = MUST_OR_THROW_OOM(format_numeric(vm, *number_format, Value(value)));
|
||||
formatted_value = MUST_OR_THROW_OOM(format_numeric(vm, *number_format, Value(value))).to_deprecated_string();
|
||||
break;
|
||||
|
||||
// ix. Else if f is "2-digit", then
|
||||
case ::Locale::CalendarPatternStyle::TwoDigit:
|
||||
// 1. Let fv be FormatNumeric(nf2, v).
|
||||
formatted_value = MUST_OR_THROW_OOM(format_numeric(vm, *number_format2, Value(value)));
|
||||
formatted_value = MUST_OR_THROW_OOM(format_numeric(vm, *number_format2, Value(value))).to_deprecated_string();
|
||||
|
||||
// 2. If the "length" property of fv is greater than 2, let fv be the substring of fv containing the last two characters.
|
||||
// NOTE: The first length check here isn't enough, but lets us avoid UTF-16 transcoding when the formatted value is ASCII.
|
||||
|
||||
Reference in New Issue
Block a user