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

LibUnicode: Generate per-locale data for the "noon" fixed day period

Note that not all locales have this day period.
This commit is contained in:
Timothy Flynn 2022-07-21 14:29:21 -04:00 committed by Linus Groh
parent 16b673eaa9
commit 32c07bc6c3
2 changed files with 7 additions and 1 deletions

View file

@ -590,6 +590,8 @@ static Optional<Unicode::DayPeriod> day_period_from_string(StringView day_period
return Unicode::DayPeriod::AM; return Unicode::DayPeriod::AM;
if (day_period == "pm"sv) if (day_period == "pm"sv)
return Unicode::DayPeriod::PM; return Unicode::DayPeriod::PM;
if (day_period == "noon"sv)
return Unicode::DayPeriod::Noon;
if (day_period == "morning1"sv) if (day_period == "morning1"sv)
return Unicode::DayPeriod::Morning1; return Unicode::DayPeriod::Morning1;
if (day_period == "morning2"sv) if (day_period == "morning2"sv)
@ -1364,7 +1366,7 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
auto const& narrow_symbols = symbols_object.get("narrow"sv).as_object(); auto const& narrow_symbols = symbols_object.get("narrow"sv).as_object();
auto const& short_symbols = symbols_object.get("abbreviated"sv).as_object(); auto const& short_symbols = symbols_object.get("abbreviated"sv).as_object();
auto const& long_symbols = symbols_object.get("wide"sv).as_object(); auto const& long_symbols = symbols_object.get("wide"sv).as_object();
auto symbol_lists = create_symbol_lists(10); auto symbol_lists = create_symbol_lists(11);
auto append_symbol = [&](auto& symbols, auto const& key, auto symbol) { auto append_symbol = [&](auto& symbols, auto const& key, auto symbol) {
if (auto day_period = day_period_from_string(key); day_period.has_value()) if (auto day_period = day_period_from_string(key); day_period.has_value())
@ -1613,6 +1615,9 @@ static ErrorOr<void> parse_day_periods(String core_path, UnicodeLocaleData& loca
}; };
auto parse_day_period = [&](auto const& symbol, auto const& ranges) -> Optional<DayPeriod> { auto parse_day_period = [&](auto const& symbol, auto const& ranges) -> Optional<DayPeriod> {
if (!ranges.has("_from"sv))
return {};
auto day_period = day_period_from_string(symbol); auto day_period = day_period_from_string(symbol);
if (!day_period.has_value()) if (!day_period.has_value())
return {}; return {};

View file

@ -50,6 +50,7 @@ enum class Weekday : u8 {
enum class DayPeriod : u8 { enum class DayPeriod : u8 {
AM, AM,
PM, PM,
Noon,
Morning1, Morning1,
Morning2, Morning2,
Afternoon1, Afternoon1,