mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 19:59:17 +00:00
LibUnicode: Parse and generate regional hour cycles
Unlike most data in the CLDR, hour cycles are not stored on a per-locale
basis. Instead, they are keyed by a string that is usually a region, but
sometimes is a locale. Therefore, given a locale, to determine the hour
cycles for that locale, we:
1. Check if the locale itself is assigned hour cycles.
2. If the locale has a region, check if that region is assigned hour
cycles.
3. Otherwise, maximize that locale, and if the maximized locale has
a region, check if that region is assigned hour cycles.
4. If the above all fail, fallback to the "001" region.
Further, each locale's default hour cycle is the first assigned hour
cycle.
This commit is contained in:
committed by
Linus Groh
parent
15fc03ef34
commit
48ce72e472
@@ -15,6 +15,13 @@
|
||||
|
||||
namespace Unicode {
|
||||
|
||||
enum class HourCycle : u8 {
|
||||
H11,
|
||||
H12,
|
||||
H23,
|
||||
H24,
|
||||
};
|
||||
|
||||
enum class CalendarPatternStyle : u8 {
|
||||
Narrow,
|
||||
Short,
|
||||
@@ -54,8 +61,12 @@ struct CalendarFormat {
|
||||
CalendarPattern short_format {};
|
||||
};
|
||||
|
||||
HourCycle hour_cycle_from_string(StringView hour_cycle);
|
||||
StringView hour_cycle_to_string(HourCycle hour_cycle);
|
||||
CalendarPatternStyle calendar_pattern_style_from_string(StringView style);
|
||||
StringView calendar_pattern_style_to_string(CalendarPatternStyle style);
|
||||
Vector<Unicode::HourCycle> get_regional_hour_cycles(StringView locale);
|
||||
Optional<Unicode::HourCycle> get_default_regional_hour_cycle(StringView locale);
|
||||
Optional<CalendarFormat> get_calendar_format(StringView locale, StringView calendar, CalendarFormatType type);
|
||||
Vector<CalendarPattern> get_calendar_available_formats(StringView locale, StringView calendar);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user