mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibJS: Port ListFormat and PatternPartition to String
This commit is contained in:
parent
20536897e4
commit
1bcde5d216
10 changed files with 53 additions and 54 deletions
|
@ -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, move(formatted_value) });
|
||||
result.append({ "fractionalSecond"sv, TRY_OR_THROW_OOM(vm, String::from_deprecated_string(formatted_value)) });
|
||||
}
|
||||
|
||||
// d. Else if p is equal to "dayPeriod", then
|
||||
|
@ -640,7 +640,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
formatted_value = *symbol;
|
||||
|
||||
// iii. Append a new Record { [[Type]]: p, [[Value]]: fv } as the last element of the list result.
|
||||
result.append({ "dayPeriod"sv, move(formatted_value) });
|
||||
result.append({ "dayPeriod"sv, TRY_OR_THROW_OOM(vm, String::from_deprecated_string(formatted_value)) });
|
||||
}
|
||||
|
||||
// e. Else if p is equal to "timeZoneName", then
|
||||
|
@ -657,7 +657,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
auto formatted_value = ::Locale::format_time_zone(data_locale, value, style, local_time.time_since_epoch());
|
||||
|
||||
// iv. Append a new Record { [[Type]]: p, [[Value]]: fv } as the last element of the list result.
|
||||
result.append({ "timeZoneName"sv, move(formatted_value) });
|
||||
result.append({ "timeZoneName"sv, TRY_OR_THROW_OOM(vm, String::from_deprecated_string(formatted_value)) });
|
||||
}
|
||||
|
||||
// f. Else if p matches a Property column of the row in Table 6, then
|
||||
|
@ -750,7 +750,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
}
|
||||
|
||||
// xi. Append a new Record { [[Type]]: p, [[Value]]: fv } as the last element of the list result.
|
||||
result.append({ style_and_value->name, move(formatted_value) });
|
||||
result.append({ style_and_value->name, TRY_OR_THROW_OOM(vm, String::from_deprecated_string(formatted_value)) });
|
||||
}
|
||||
|
||||
// g. Else if p is equal to "ampm", then
|
||||
|
@ -774,7 +774,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
}
|
||||
|
||||
// iv. Append a new Record { [[Type]]: "dayPeriod", [[Value]]: fv } as the last element of the list result.
|
||||
result.append({ "dayPeriod"sv, move(formatted_value) });
|
||||
result.append({ "dayPeriod"sv, TRY_OR_THROW_OOM(vm, String::from_deprecated_string(formatted_value)) });
|
||||
}
|
||||
|
||||
// h. Else if p is equal to "relatedYear", then
|
||||
|
@ -799,7 +799,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
// to adhere to the selected locale. This depends on other generated data, so it is deferred to here.
|
||||
else if (part == "decimal"sv) {
|
||||
auto decimal_symbol = ::Locale::get_number_system_symbol(data_locale, date_time_format.numbering_system(), ::Locale::NumericSymbol::Decimal).value_or("."sv);
|
||||
result.append({ "literal"sv, decimal_symbol });
|
||||
result.append({ "literal"sv, TRY_OR_THROW_OOM(vm, String::from_utf8(decimal_symbol)) });
|
||||
}
|
||||
|
||||
// j. Else,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue