summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-09-22 08:58:13 -0400
committerLinus Groh <mail@linusgroh.de>2022-09-22 14:39:24 +0100
commit82e730eba10c7dbfad4a15056b26efa943920f71 (patch)
tree5ef9d1189ee759f6c71b06d9426684e9d51b896a /Userland/Libraries/LibJS/Runtime
parent5f4c59e2c16f8ae3823b9e30636e464aa324f8c2 (diff)
downloadserenity-82e730eba10c7dbfad4a15056b26efa943920f71.zip
LibJS: Change default time display options to "always" for digital style
This is a normative change in the Intl.DurationFormat proposal. See: https://github.com/tc39/proposal-intl-duration-format/commit/d28076b
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
index 87ed86dd81..e07a8a0a7b 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
@@ -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();