|
@@ -435,13 +435,18 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(Gl
|
|
|
// t. Else,
|
|
|
else {
|
|
|
// i. Let pr be ? Construct(%PluralRules%, « durationFormat.[[Locale]] »).
|
|
|
+ auto* plural_rules = TRY(construct(global_object, *global_object.intl_plural_rules_constructor(), js_string(vm, duration_format.locale())));
|
|
|
+
|
|
|
// ii. Let prv be ! ResolvePlural(pr, value).
|
|
|
- // FIXME: Use ResolvePlural when Intl.PluralRules is implemented.
|
|
|
+ auto plurality = resolve_plural(global_object, static_cast<PluralRules&>(*plural_rules), value);
|
|
|
+
|
|
|
auto formats = Unicode::get_unit_formats(data_locale, duration_instances_component.unit_singular, static_cast<Unicode::Style>(style));
|
|
|
- auto pattern = Unicode::select_pattern_with_plurality(formats, value.as_double()).release_value();
|
|
|
+ auto pattern = formats.find_if([&](auto& p) { return p.plurality == plurality; });
|
|
|
+ if (pattern == formats.end())
|
|
|
+ continue;
|
|
|
|
|
|
// iii. Let template be the current value of the prv slot of the unit slot of the style slot of dataLocaleData.[[formats]].
|
|
|
- auto template_ = convert_number_format_pattern_to_duration_format_template(pattern);
|
|
|
+ auto template_ = convert_number_format_pattern_to_duration_format_template(*pattern);
|
|
|
|
|
|
// FIXME: MakePartsList takes a list, not a string, so likely missing spec step: Let fv be ! PartitionNumberPattern(nf, value).
|
|
|
auto formatted_value = partition_number_pattern(global_object, *number_format, value);
|