#[doc(inline)]
#[doc = "\n"] pub use icu_locale_core::preferences::extensions::unicode::keywords::CalendarAlgorithm;
#[doc = "\n"] pub use icu_locale_core::preferences::extensions::unicode::keywords::FirstDay;
#[doc(inline)]
#[doc = "\n"] pub use icu_locale_core::preferences::extensions::unicode::keywords::HijriCalendarAlgorithm;
use icu_locale_core::preferences::define_preferences;
define_preferences!(
[Copy]
CalendarPreferences,
{
calendar_algorithm: CalendarAlgorithm
}
);
define_preferences!(
[Copy]
WeekPreferences,
{
first_weekday: FirstDay
}
);
impl CalendarPreferences {
pub fn resolved_algorithm(self) -> CalendarAlgorithm {
use icu_locale_core::subtags::{region, Region};
const AE: Region = region!("AE");
const BH: Region = region!("BH");
const KW: Region = region!("KW");
const QA: Region = region!("QA");
const SA: Region = region!("SA");
const TH: Region = region!("TH");
const AF: Region = region!("AF");
const IR: Region = region!("IR");
match (
self.calendar_algorithm,
self.locale_preferences
.to_data_locale_region_priority()
.region,
) {
(
Some(CalendarAlgorithm::Hijri(None | Some(HijriCalendarAlgorithm::Rgsa))),
Some(AE | BH | KW | QA | SA),
) => CalendarAlgorithm::Hijri(Some(HijriCalendarAlgorithm::Umalqura)),
(Some(CalendarAlgorithm::Hijri(None | Some(HijriCalendarAlgorithm::Rgsa))), _) => {
CalendarAlgorithm::Hijri(Some(HijriCalendarAlgorithm::Civil))
}
(Some(a), _) => a,
(None, Some(TH)) => CalendarAlgorithm::Buddhist,
(None, Some(AF | IR)) => CalendarAlgorithm::Persian,
(None, _) => CalendarAlgorithm::Gregory,
}
}
}