1#![allow(non_snake_case)]
6
7use crate::extensions::unicode::{value, Value};
8use crate::preferences::extensions::unicode::enum_keyword;
9use crate::preferences::extensions::unicode::errors::PreferencesParseError;
10use crate::subtags::{subtag, Subtag};
11
12#[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_fields_are_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!(
13 HijriCalendarAlgorithm {
17 Umalqura,
19 Tbla,
21 Civil,
23 Rgsa
25});
26
27fn handle_aliases(v: &Value) -> Option<CalendarAlgorithm> {
29 if *v == 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"));
}
})
}value!("islamicc") {
30 return Some(CalendarAlgorithm::Hijri(Some(
31 HijriCalendarAlgorithm::Civil,
32 )));
33 } else if v.as_subtags_slice() == [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"));
}
}
}subtag!("ethiopic"), const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("amete".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: amete"));
}
}
}subtag!("amete"), const {
use crate::subtags::Subtag;
match Subtag::try_from_utf8("alem".as_bytes()) {
Ok(r) => r,
_ => {
::core::panicking::panic_fmt(format_args!("Invalid subtags::Subtag: alem"));
}
}
}subtag!("alem")] {
34 return Some(CalendarAlgorithm::Ethioaa);
35 }
36 None
37}
38
39#[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_fields_are_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(Self::UNICODE_EXTENSION_KEY)
}
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 == *key {
Self::try_from(value).map(Some)
} else { Ok(None) }
}
fn unicode_extension_value(&self)
-> Option<crate::extensions::unicode::Value> {
Some((*self).into())
}
}
impl CalendarAlgorithm {
pub(crate) const UNICODE_EXTENSION_KEY: crate::extensions::unicode::Key =
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"));
}
}
};
}
impl TryFrom<&crate::extensions::unicode::Value> for CalendarAlgorithm {
type Error =
crate::preferences::extensions::unicode::errors::PreferencesParseError;
fn try_from(value: &crate::extensions::unicode::Value)
-> Result<Self, Self::Error> {
const TRUE: crate::subtags::Subtag =
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 = value;
if let Some(s) = handle_aliases(s) { return Ok(s) }
Ok(match value.get_subtag(0).copied().unwrap_or(TRUE) {
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Buddhist
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Chinese
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Coptic
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Dangi
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Ethioaa
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Ethiopic
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Gregory
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Hebrew
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Indian
}
s if
s ==
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"));
}
}
} => {
const _: () =
if !!#[allow(non_exhaustive_omitted_patterns)] match 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"));
}
}
} {
TRUE => true,
_ => false,
} {
{
::core::panicking::panic_fmt(format_args!("true value not allowed with second level"));
}
};
if value.get_subtag(2).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Hijri(match value.get_subtag(1) {
None => None,
Some(s) if
s ==
&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"));
}
}
} => Some(HijriCalendarAlgorithm::Umalqura),
Some(s) if
s ==
&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"));
}
}
} => Some(HijriCalendarAlgorithm::Tbla),
Some(s) if
s ==
&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"));
}
}
} => Some(HijriCalendarAlgorithm::Civil),
Some(s) if
s ==
&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"));
}
}
} => Some(HijriCalendarAlgorithm::Rgsa),
_ => return Err(Self::Error::InvalidKeywordValue),
})
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Iso8601
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Japanese
}
s if
s ==
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"));
}
}
} => {
if value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
CalendarAlgorithm::Persian
}
s if
s ==
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 value.get_subtag(1).is_some() {
return Err(Self::Error::InvalidKeywordValue);
}
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!(
40 CalendarAlgorithm {
48 ("buddhist" => Buddhist),
50 ("chinese" => Chinese),
52 ("coptic" => Coptic),
54 ("dangi" => Dangi),
56 ("ethioaa" => Ethioaa),
58 ("ethiopic" => Ethiopic),
60 ("gregory" => Gregory),
62 ("hebrew" => Hebrew),
64 ("indian" => Indian),
66 ("islamic" => Hijri(HijriCalendarAlgorithm) {
68 ("umalqura" => Umalqura),
69 ("tbla" => Tbla),
70 ("civil" => Civil),
71 ("rgsa" => Rgsa)
72 }),
73 ("iso8601" => Iso8601),
75 ("japanese" => Japanese),
77 ("persian" => Persian),
79 ("roc" => Roc)
81}, "ca", s, if let Some(s) = handle_aliases(s) { return Ok(s) });
82
83#[test]
84fn test_calendar_aliases() {
85 fn test(s: &str, expectation: CalendarAlgorithm) {
86 let v = Value::try_from_str(s).unwrap();
87 let parsed = CalendarAlgorithm::try_from(&v).unwrap();
88 assert_eq!(parsed, expectation, "{s} must parse to {expectation:?}");
89 }
90
91 test("ethiopic-amete-alem", CalendarAlgorithm::Ethioaa);
92 test("ethiopic", CalendarAlgorithm::Ethiopic);
93 test("ethioaa", CalendarAlgorithm::Ethioaa);
94 test(
95 "islamicc",
96 CalendarAlgorithm::Hijri(Some(HijriCalendarAlgorithm::Civil)),
97 );
98 test(
99 "islamic-civil",
100 CalendarAlgorithm::Hijri(Some(HijriCalendarAlgorithm::Civil)),
101 );
102 test(
103 "islamic-rgsa",
104 CalendarAlgorithm::Hijri(Some(HijriCalendarAlgorithm::Rgsa)),
105 );
106 test("islamic", CalendarAlgorithm::Hijri(None));
107}