mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibUnicode: Generate data about DurationFormat-required units as well
This commit is contained in:
parent
573061e76c
commit
f4785e2468
2 changed files with 10 additions and 1 deletions
|
@ -637,7 +637,10 @@ static ErrorOr<void> parse_units(String locale_units_path, UnicodeLocaleData& lo
|
|||
// LibUnicode generally tries to avoid being directly dependent on ECMA-402, but this rather significantly reduces the amount
|
||||
// of data generated here, and ECMA-402 is currently the only consumer of this data.
|
||||
constexpr auto sanctioned_units = JS::Intl::sanctioned_single_unit_identifiers();
|
||||
return find(sanctioned_units.begin(), sanctioned_units.end(), unit_name) != sanctioned_units.end();
|
||||
if (find(sanctioned_units.begin(), sanctioned_units.end(), unit_name) != sanctioned_units.end())
|
||||
return true;
|
||||
static constexpr auto extra_sanctioned_units = JS::Intl::extra_sanctioned_single_unit_identifiers();
|
||||
return find(extra_sanctioned_units.begin(), extra_sanctioned_units.end(), unit_name) != extra_sanctioned_units.end();
|
||||
};
|
||||
|
||||
auto parse_units_object = [&](auto const& units_object, Unicode::Style style) {
|
||||
|
|
|
@ -59,6 +59,12 @@ constexpr auto sanctioned_single_unit_identifiers()
|
|||
return AK::Array { "acre"sv, "bit"sv, "byte"sv, "celsius"sv, "centimeter"sv, "day"sv, "degree"sv, "fahrenheit"sv, "fluid-ounce"sv, "foot"sv, "gallon"sv, "gigabit"sv, "gigabyte"sv, "gram"sv, "hectare"sv, "hour"sv, "inch"sv, "kilobit"sv, "kilobyte"sv, "kilogram"sv, "kilometer"sv, "liter"sv, "megabit"sv, "megabyte"sv, "meter"sv, "mile"sv, "mile-scandinavian"sv, "milliliter"sv, "millimeter"sv, "millisecond"sv, "minute"sv, "month"sv, "ounce"sv, "percent"sv, "petabyte"sv, "pound"sv, "second"sv, "stone"sv, "terabit"sv, "terabyte"sv, "week"sv, "yard"sv, "year"sv };
|
||||
}
|
||||
|
||||
// Additional single units used in ECMAScript required by the Intl.DurationFormat proposal
|
||||
constexpr auto extra_sanctioned_single_unit_identifiers()
|
||||
{
|
||||
return AK::Array { "microsecond"sv, "nanosecond"sv };
|
||||
}
|
||||
|
||||
Optional<Unicode::LocaleID> is_structurally_valid_language_tag(StringView locale);
|
||||
String canonicalize_unicode_locale_id(Unicode::LocaleID& locale);
|
||||
bool is_well_formed_currency_code(StringView currency);
|
||||
|
|
Loading…
Add table
Reference in a new issue