1#![allow(non_snake_case)]
6
7use crate::preferences::extensions::unicode::enum_keyword;
8
9#[non_exhaustive]
#[doc = r" Hijri Calendar sub-type"]
#[doc = r""]
#[doc =
r" The list is based on [`CLDR Calendars`](https://github.com/unicode-org/cldr/blob/main/common/bcp47/calendar.xml)"]
pub enum HijriCalendarAlgorithm {
#[doc = r" Hijri calendar, Umm al-Qura"]
Umalqura,
#[doc =
r" Hijri calendar, tabular (intercalary years \[2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch)"]
Tbla,
#[doc =
r" Hijri calendar, tabular (intercalary years \[2,5,7,10,13,16,18,21,24,26,29] - civil epoch)"]
Civil,
#[doc = r" Hijri calendar, Saudi Arabia sighting"]
Rgsa,
}
#[automatically_derived]
impl ::core::fmt::Debug for HijriCalendarAlgorithm {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
HijriCalendarAlgorithm::Umalqura => "Umalqura",
HijriCalendarAlgorithm::Tbla => "Tbla",
HijriCalendarAlgorithm::Civil => "Civil",
HijriCalendarAlgorithm::Rgsa => "Rgsa",
})
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for HijriCalendarAlgorithm { }
#[automatically_derived]
impl ::core::clone::Clone for HijriCalendarAlgorithm {
#[inline]
fn clone(&self) -> HijriCalendarAlgorithm { *self }
}
#[automatically_derived]
impl ::core::cmp::Eq for HijriCalendarAlgorithm {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {}
}
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for HijriCalendarAlgorithm { }
#[automatically_derived]
impl ::core::cmp::PartialEq for HijriCalendarAlgorithm {
#[inline]
fn eq(&self, other: &HijriCalendarAlgorithm) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}
#[automatically_derived]
impl ::core::marker::Copy for HijriCalendarAlgorithm { }
#[automatically_derived]
impl ::core::hash::Hash for HijriCalendarAlgorithm {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}enum_keyword!(
10 HijriCalendarAlgorithm {
14 Umalqura,
16 Tbla,
18 Civil,
20 Rgsa
22});
23
24#[non_exhaustive]
#[doc = r" A Unicode Calendar Identifier defines a type of calendar."]
#[doc = r""]
#[doc =
r" This selects calendar-specific data within a locale used for formatting and parsing,"]
#[doc =
r" such as date/time symbols and patterns; it also selects supplemental calendarData used"]
#[doc =
r" for calendrical calculations. The value can affect the computation of the first day of the week."]
#[doc = r""]
#[doc =
r" The valid values are listed in [LDML](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier)."]
pub enum CalendarAlgorithm {
#[doc =
r" Thai Buddhist calendar (same as Gregorian except for the year)"]
Buddhist,
#[doc = r" Traditional Chinese calendar"]
Chinese,
#[doc = r" Coptic calendar"]
Coptic,
#[doc = r" Traditional Korean calendar"]
Dangi,
#[doc = r" Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E)"]
Ethioaa,
#[doc = r" Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.)"]
Ethiopic,
#[doc = r" Gregorian calendar"]
Gregory,
#[doc = r" Traditional Hebrew calendar"]
Hebrew,
#[doc = r" Indian calendar"]
Indian,
#[doc = r" Hijri calendar"]
Hijri(Option<HijriCalendarAlgorithm>),
#[doc =
r" ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules)"]
Iso8601,
#[doc = r" Japanese Imperial calendar"]
Japanese,
#[doc = r" Persian calendar"]
Persian,
#[doc = r" Republic of China calendar"]
Roc,
}
#[automatically_derived]
impl ::core::fmt::Debug for CalendarAlgorithm {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
CalendarAlgorithm::Buddhist =>
::core::fmt::Formatter::write_str(f, "Buddhist"),
CalendarAlgorithm::Chinese =>
::core::fmt::Formatter::write_str(f, "Chinese"),
CalendarAlgorithm::Coptic =>
::core::fmt::Formatter::write_str(f, "Coptic"),
CalendarAlgorithm::Dangi =>
::core::fmt::Formatter::write_str(f, "Dangi"),
CalendarAlgorithm::Ethioaa =>
::core::fmt::Formatter::write_str(f, "Ethioaa"),
CalendarAlgorithm::Ethiopic =>
::core::fmt::Formatter::write_str(f, "Ethiopic"),
CalendarAlgorithm::Gregory =>
::core::fmt::Formatter::write_str(f, "Gregory"),
CalendarAlgorithm::Hebrew =>
::core::fmt::Formatter::write_str(f, "Hebrew"),
CalendarAlgorithm::Indian =>
::core::fmt::Formatter::write_str(f, "Indian"),
CalendarAlgorithm::Hijri(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Hijri",
&__self_0),
CalendarAlgorithm::Iso8601 =>
::core::fmt::Formatter::write_str(f, "Iso8601"),
CalendarAlgorithm::Japanese =>
::core::fmt::Formatter::write_str(f, "Japanese"),
CalendarAlgorithm::Persian =>
::core::fmt::Formatter::write_str(f, "Persian"),
CalendarAlgorithm::Roc =>
::core::fmt::Formatter::write_str(f, "Roc"),
}
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for CalendarAlgorithm { }
#[automatically_derived]
impl ::core::clone::Clone for CalendarAlgorithm {
#[inline]
fn clone(&self) -> CalendarAlgorithm {
let _:
::core::clone::AssertParamIsClone<Option<HijriCalendarAlgorithm>>;
*self
}
}
#[automatically_derived]
impl ::core::cmp::Eq for CalendarAlgorithm {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<Option<HijriCalendarAlgorithm>>;
}
}
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for CalendarAlgorithm { }
#[automatically_derived]
impl ::core::cmp::PartialEq for CalendarAlgorithm {
#[inline]
fn eq(&self, other: &CalendarAlgorithm) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(CalendarAlgorithm::Hijri(__self_0),
CalendarAlgorithm::Hijri(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}
#[automatically_derived]
impl ::core::marker::Copy for CalendarAlgorithm { }
#[automatically_derived]
impl ::core::hash::Hash for CalendarAlgorithm {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
CalendarAlgorithm::Hijri(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}
impl crate::preferences::PreferenceKey for CalendarAlgorithm {
fn unicode_extension_key() -> Option<crate::extensions::unicode::Key> {
Some(const {
use crate::extensions::unicode::Key;
match Key::try_from_utf8("ca".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid extensions::unicode::Key: ca"));
}
}
})
}
fn try_from_key_value(key: &crate::extensions::unicode::Key,
value: &crate::extensions::unicode::Value)
->
Result<Option<Self>,
crate::preferences::extensions::unicode::errors::PreferencesParseError> {
if Self::unicode_extension_key() == Some(*key) {
Self::try_from(value).map(Some)
} else { Ok(None) }
}
fn unicode_extension_value(&self)
-> Option<crate::extensions::unicode::Value> {
Some((*self).into())
}
}
impl TryFrom<&crate::extensions::unicode::Value> for CalendarAlgorithm {
type Error =
crate::preferences::extensions::unicode::errors::PreferencesParseError;
fn try_from(s: &crate::extensions::unicode::Value)
-> Result<Self, Self::Error> {
let subtag =
s.get_subtag(0).unwrap_or(&const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("true".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: true"));
}
}
});
#[allow(unused_imports)]
use crate::extensions::unicode::value;
let s = s;
if *s ==
const {
crate::extensions::unicode::Value::from_subtag(match crate::subtags::Subtag::try_from_utf8("islamicc".as_bytes())
{
Ok(r) => Some(r),
_ => {
::core::panicking::panic_fmt(format_args!("Invalid Unicode extension value: islamicc"));
}
})
} {
return Ok(Self::Hijri(Some(HijriCalendarAlgorithm::Civil)));
}
Ok(match subtag.as_str() {
"buddhist" => { CalendarAlgorithm::Buddhist }
"chinese" => { CalendarAlgorithm::Chinese }
"coptic" => { CalendarAlgorithm::Coptic }
"dangi" => { CalendarAlgorithm::Dangi }
"ethioaa" => { CalendarAlgorithm::Ethioaa }
"ethiopic" => { CalendarAlgorithm::Ethiopic }
"gregory" => { CalendarAlgorithm::Gregory }
"hebrew" => { CalendarAlgorithm::Hebrew }
"indian" => { CalendarAlgorithm::Indian }
"islamic" => {
{
let sv =
s.get_subtag(1).and_then(|st|
{
match st.as_str() {
"umalqura" => Some(HijriCalendarAlgorithm::Umalqura),
"tbla" => Some(HijriCalendarAlgorithm::Tbla),
"civil" => Some(HijriCalendarAlgorithm::Civil),
"rgsa" => Some(HijriCalendarAlgorithm::Rgsa),
_ => None,
}
});
CalendarAlgorithm::Hijri(sv)
}
}
"iso8601" => { CalendarAlgorithm::Iso8601 }
"japanese" => { CalendarAlgorithm::Japanese }
"persian" => { CalendarAlgorithm::Persian }
"roc" => { CalendarAlgorithm::Roc }
_ => { return Err(Self::Error::InvalidKeywordValue); }
})
}
}
impl From<CalendarAlgorithm> for crate::extensions::unicode::Value {
fn from(input: CalendarAlgorithm) -> crate::extensions::unicode::Value {
let f;
#[allow(unused_mut)]
let mut s = None;
match input
{
#[allow(non_snake_case)]
CalendarAlgorithm::Buddhist => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("buddhist".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: buddhist"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Chinese => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("chinese".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: chinese"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Coptic => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("coptic".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: coptic"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Dangi => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("dangi".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: dangi"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Ethioaa => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("ethioaa".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: ethioaa"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Ethiopic => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("ethiopic".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: ethiopic"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Gregory => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("gregory".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: gregory"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Hebrew => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("hebrew".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: hebrew"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Indian => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("indian".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: indian"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Hijri(HijriCalendarAlgorithm) => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("islamic".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: islamic"));
}
}
};
if let Some(v2) = HijriCalendarAlgorithm {
match v2 {
HijriCalendarAlgorithm::Umalqura =>
s =
Some(const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("umalqura".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: umalqura"));
}
}
}),
HijriCalendarAlgorithm::Tbla =>
s =
Some(const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("tbla".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: tbla"));
}
}
}),
HijriCalendarAlgorithm::Civil =>
s =
Some(const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("civil".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: civil"));
}
}
}),
HijriCalendarAlgorithm::Rgsa =>
s =
Some(const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("rgsa".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: rgsa"));
}
}
}),
}
}
}
#[allow(non_snake_case)]
CalendarAlgorithm::Iso8601 => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("iso8601".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: iso8601"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Japanese => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("japanese".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: japanese"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Persian => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("persian".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: persian"));
}
}
};
}
#[allow(non_snake_case)]
CalendarAlgorithm::Roc => {
f =
const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("roc".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: roc"));
}
}
};
}
}
if let Some(s) = s {
crate::extensions::unicode::Value::from_two_subtags(f, s)
} else { crate::extensions::unicode::Value::from_subtag(Some(f)) }
}
}
impl CalendarAlgorithm {
pub const fn as_str(&self) -> &'static str {
match self
{
#[allow(non_snake_case)]
Self::Buddhist => {
return "buddhist";
}
#[allow(non_snake_case)]
Self::Chinese => {
return "chinese";
}
#[allow(non_snake_case)]
Self::Coptic => {
return "coptic";
}
#[allow(non_snake_case)]
Self::Dangi => {
return "dangi";
}
#[allow(non_snake_case)]
Self::Ethioaa => {
return "ethioaa";
}
#[allow(non_snake_case)]
Self::Ethiopic => {
return "ethiopic";
}
#[allow(non_snake_case)]
Self::Gregory => {
return "gregory";
}
#[allow(non_snake_case)]
Self::Hebrew => {
return "hebrew";
}
#[allow(non_snake_case)]
Self::Indian => {
return "indian";
}
#[allow(non_snake_case)]
Self::Hijri(HijriCalendarAlgorithm) => {
if let Some(v2) = HijriCalendarAlgorithm {
return match v2 {
HijriCalendarAlgorithm::Umalqura => "islamic-umalqura",
HijriCalendarAlgorithm::Tbla => "islamic-tbla",
HijriCalendarAlgorithm::Civil => "islamic-civil",
HijriCalendarAlgorithm::Rgsa => "islamic-rgsa",
};
}
return "islamic";
}
#[allow(non_snake_case)]
Self::Iso8601 => {
return "iso8601";
}
#[allow(non_snake_case)]
Self::Japanese => {
return "japanese";
}
#[allow(non_snake_case)]
Self::Persian => {
return "persian";
}
#[allow(non_snake_case)]
Self::Roc => {
return "roc";
}
}
}
}enum_keyword!(
25 CalendarAlgorithm {
33 ("buddhist" => Buddhist),
35 ("chinese" => Chinese),
37 ("coptic" => Coptic),
39 ("dangi" => Dangi),
41 ("ethioaa" => Ethioaa),
43 ("ethiopic" => Ethiopic),
45 ("gregory" => Gregory),
47 ("hebrew" => Hebrew),
49 ("indian" => Indian),
51 ("islamic" => Hijri(HijriCalendarAlgorithm) {
53 ("umalqura" => Umalqura),
54 ("tbla" => Tbla),
55 ("civil" => Civil),
56 ("rgsa" => Rgsa)
57 }),
58 ("iso8601" => Iso8601),
60 ("japanese" => Japanese),
62 ("persian" => Persian),
64 ("roc" => Roc)
66}, "ca", s, if *s == value!("islamicc") { return Ok(Self::Hijri(Some(HijriCalendarAlgorithm::Civil))); });