1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

LibJS: Change default time display options to "always" for digital style

This is a normative change in the Intl.DurationFormat proposal. See:
d28076b
This commit is contained in:
Timothy Flynn 2022-09-22 08:58:13 -04:00 committed by Linus Groh
parent 5f4c59e2c1
commit 82e730eba1
2 changed files with 48 additions and 13 deletions

View file

@ -244,23 +244,32 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
// 3. If style is undefined, then
if (style_value.is_undefined()) {
// a. Set displayDefault to "auto".
display_default = "auto"sv;
// b. If baseStyle is "digital", then
// a. If baseStyle is "digital", then
if (base_style == "digital"sv) {
// i. Set style to digitalBase.
// i. If unit is not one of "hours", "minutes", or "seconds", then
if (!unit.is_one_of("hours"sv, "minutes"sv, "seconds"sv)) {
// 1. Set displayDefault to "auto".
display_default = "auto"sv;
}
// ii. Set style to digitalBase.
style = digital_base;
}
// c. Else if prevStyle is "numeric" or "2-digit", then
else if (previous_style == "numeric"sv || previous_style == "2-digit"sv) {
// i. Set style to "numeric".
style = "numeric"sv;
}
// d. Else,
// b. Else,
else {
// i. Set style to baseStyle.
style = base_style;
// i. Set displayDefault to "auto".
display_default = "auto"sv;
// ii. If prevStyle is "numeric" or "2-digit", then
if (previous_style == "numeric"sv || previous_style == "2-digit"sv) {
// 1. Set style to "numeric".
style = "numeric"sv;
}
// iii. Else,
else {
// 1. Set style to baseStyle.
style = base_style;
}
}
} else {
style = style_value.as_string().string();