diff --git a/components/calendar/src/any_calendar.rs b/components/calendar/src/any_calendar.rs index cf80134d0bb..dabded450f4 100644 --- a/components/calendar/src/any_calendar.rs +++ b/components/calendar/src/any_calendar.rs @@ -1544,20 +1544,19 @@ mod tests { fn single_test_roundtrip( calendar: Ref, - era: &str, + era: Option<&str>, year: i32, month_code: &str, day: u8, ) { let month = types::MonthCode(month_code.parse().expect("month code must parse")); - let date = - Date::try_new_from_codes(Some(era), year, month, day, calendar).unwrap_or_else(|e| { - panic!( - "Failed to construct date for {} with {era:?}, {year}, {month}, {day}: {e:?}", - calendar.debug_name(), - ) - }); + let date = Date::try_new_from_codes(era, year, month, day, calendar).unwrap_or_else(|e| { + panic!( + "Failed to construct date for {} with {era:?}, {year}, {month}, {day}: {e:?}", + calendar.debug_name(), + ) + }); let roundtrip_year = date.year(); // FIXME: these APIs should be improved @@ -1582,7 +1581,7 @@ mod tests { fn single_test_error( calendar: Ref, - era: &str, + era: Option<&str>, year: i32, month_code: &str, day: u8, @@ -1590,7 +1589,7 @@ mod tests { ) { let month = types::MonthCode(month_code.parse().expect("month code must parse")); - let date = Date::try_new_from_codes(Some(era), year, month, day, calendar); + let date = Date::try_new_from_codes(era, year, month, day, calendar); assert_eq!( date, Err(error), @@ -1636,26 +1635,26 @@ mod tests { let persian = Ref(&persian); let roc = Ref(&roc); - single_test_roundtrip(buddhist, "be", 100, "M03", 1); - single_test_roundtrip(buddhist, "be", 2000, "M03", 1); - single_test_roundtrip(buddhist, "be", -100, "M03", 1); + single_test_roundtrip(buddhist, Some("be"), 100, "M03", 1); + single_test_roundtrip(buddhist, None, 2000, "M03", 1); + single_test_roundtrip(buddhist, Some("be"), -100, "M03", 1); single_test_error( buddhist, - "be", + Some("be"), 100, "M13", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M13"))), ); - single_test_roundtrip(coptic, "coptic", 100, "M03", 1); - single_test_roundtrip(coptic, "coptic", 2000, "M03", 1); + single_test_roundtrip(coptic, Some("am"), 100, "M03", 1); + single_test_roundtrip(coptic, None, 2000, "M03", 1); // fails ISO roundtrip - // single_test_roundtrip(coptic, "bd", 100, "M03", 1); - single_test_roundtrip(coptic, "coptic", 100, "M13", 1); + // single_test_roundtrip(coptic, Some("bd"), 100, "M03", 1); + single_test_roundtrip(coptic, Some("am"), 100, "M13", 1); single_test_error( coptic, - "coptic", + Some("am"), 100, "M14", 1, @@ -1663,7 +1662,7 @@ mod tests { ); single_test_error( coptic, - "coptic", + Some("am"), 0, "M03", 1, @@ -1676,7 +1675,7 @@ mod tests { ); single_test_error( coptic, - "coptic-inverse", + Some("bd"), 0, "M03", 1, @@ -1688,14 +1687,14 @@ mod tests { }, ); - single_test_roundtrip(ethiopian, "incar", 100, "M03", 1); - single_test_roundtrip(ethiopian, "incar", 2000, "M03", 1); - single_test_roundtrip(ethiopian, "incar", 2000, "M13", 1); + single_test_roundtrip(ethiopian, Some("am"), 100, "M03", 1); + single_test_roundtrip(ethiopian, None, 2000, "M03", 1); + single_test_roundtrip(ethiopian, Some("am"), 2000, "M13", 1); // Fails ISO roundtrip due to https://github.com/unicode-org/icu4x/issues/2254 - // single_test_roundtrip(ethiopian, "mundi", 5400, "M03", 1); + // single_test_roundtrip(ethiopian, Some("aa"), 5400, "M03", 1); single_test_error( ethiopian, - "incar", + Some("am"), 0, "M03", 1, @@ -1708,7 +1707,7 @@ mod tests { ); single_test_error( ethiopian, - "mundi", + Some("aa"), 5600, "M03", 1, @@ -1721,32 +1720,32 @@ mod tests { ); single_test_error( ethiopian, - "incar", + Some("am"), 100, "M14", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M14"))), ); - single_test_roundtrip(ethioaa, "mundi", 7000, "M13", 1); - single_test_roundtrip(ethioaa, "mundi", 7000, "M13", 1); + single_test_roundtrip(ethioaa, Some("aa"), 7000, "M13", 1); + single_test_roundtrip(ethioaa, None, 7000, "M13", 1); // Fails ISO roundtrip due to https://github.com/unicode-org/icu4x/issues/2254 - // single_test_roundtrip(ethioaa, "mundi", 100, "M03", 1); + // single_test_roundtrip(ethioaa, Some("aa"), 100, "M03", 1); single_test_error( ethiopian, - "mundi", + Some("aa"), 100, "M14", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M14"))), ); - single_test_roundtrip(gregorian, "ce", 100, "M03", 1); - single_test_roundtrip(gregorian, "ce", 2000, "M03", 1); - single_test_roundtrip(gregorian, "bce", 100, "M03", 1); + single_test_roundtrip(gregorian, Some("ce"), 100, "M03", 1); + single_test_roundtrip(gregorian, None, 2000, "M03", 1); + single_test_roundtrip(gregorian, Some("bce"), 100, "M03", 1); single_test_error( gregorian, - "ce", + Some("ce"), 0, "M03", 1, @@ -1759,7 +1758,7 @@ mod tests { ); single_test_error( gregorian, - "bce", + Some("bce"), 0, "M03", 1, @@ -1773,58 +1772,59 @@ mod tests { single_test_error( gregorian, - "bce", + Some("bce"), 100, "M13", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M13"))), ); - single_test_roundtrip(indian, "saka", 100, "M03", 1); - single_test_roundtrip(indian, "saka", 2000, "M12", 1); - single_test_roundtrip(indian, "saka", -100, "M03", 1); - single_test_roundtrip(indian, "saka", 0, "M03", 1); + single_test_roundtrip(indian, Some("saka"), 100, "M03", 1); + single_test_roundtrip(indian, None, 2000, "M12", 1); + single_test_roundtrip(indian, None, -100, "M03", 1); + single_test_roundtrip(indian, Some("saka"), 0, "M03", 1); single_test_error( indian, - "saka", + Some("saka"), 100, "M13", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M13"))), ); - single_test_roundtrip(chinese, "chinese", 400, "M02", 5); - single_test_roundtrip(chinese, "chinese", 4660, "M07", 29); - single_test_roundtrip(chinese, "chinese", -100, "M11", 12); + single_test_roundtrip(chinese, None, 400, "M02", 5); + single_test_roundtrip(chinese, None, 4660, "M07", 29); + single_test_roundtrip(chinese, None, -100, "M11", 12); single_test_error( chinese, - "chinese", + None, 4658, "M13", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M13"))), ); - single_test_roundtrip(dangi, "dangi", 400, "M02", 5); - single_test_roundtrip(dangi, "dangi", 4660, "M08", 29); - single_test_roundtrip(dangi, "dangi", -1300, "M11", 12); + single_test_roundtrip(dangi, None, 400, "M02", 5); + single_test_roundtrip(dangi, None, 4660, "M08", 29); + single_test_roundtrip(dangi, None, -1300, "M11", 12); single_test_error( dangi, - "dangi", + None, 10393, "M00L", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M00L"))), ); - single_test_roundtrip(japanese, "reiwa", 3, "M03", 1); - single_test_roundtrip(japanese, "heisei", 6, "M12", 1); - single_test_roundtrip(japanese, "meiji", 10, "M03", 1); - single_test_roundtrip(japanese, "ce", 1000, "M03", 1); - single_test_roundtrip(japanese, "bce", 10, "M03", 1); + single_test_roundtrip(japanese, Some("reiwa"), 3, "M03", 1); + single_test_roundtrip(japanese, Some("heisei"), 6, "M12", 1); + single_test_roundtrip(japanese, Some("meiji"), 10, "M03", 1); + single_test_roundtrip(japanese, Some("ce"), 1000, "M03", 1); + single_test_roundtrip(japanese, None, 1000, "M03", 1); + single_test_roundtrip(japanese, Some("bce"), 10, "M03", 1); single_test_error( japanese, - "ce", + Some("ce"), 0, "M03", 1, @@ -1837,7 +1837,7 @@ mod tests { ); single_test_error( japanese, - "bce", + Some("bce"), 0, "M03", 1, @@ -1851,22 +1851,22 @@ mod tests { single_test_error( japanese, - "reiwa", + Some("reiwa"), 2, "M13", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M13"))), ); - single_test_roundtrip(japanext, "reiwa", 3, "M03", 1); - single_test_roundtrip(japanext, "heisei", 6, "M12", 1); - single_test_roundtrip(japanext, "meiji", 10, "M03", 1); - single_test_roundtrip(japanext, "tenpyokampo-749", 1, "M04", 20); - single_test_roundtrip(japanext, "ce", 100, "M03", 1); - single_test_roundtrip(japanext, "bce", 10, "M03", 1); + single_test_roundtrip(japanext, Some("reiwa"), 3, "M03", 1); + single_test_roundtrip(japanext, Some("heisei"), 6, "M12", 1); + single_test_roundtrip(japanext, Some("meiji"), 10, "M03", 1); + single_test_roundtrip(japanext, Some("tenpyokampo-749"), 1, "M04", 20); + single_test_roundtrip(japanext, Some("ce"), 100, "M03", 1); + single_test_roundtrip(japanext, Some("bce"), 10, "M03", 1); single_test_error( japanext, - "ce", + Some("ce"), 0, "M03", 1, @@ -1879,7 +1879,7 @@ mod tests { ); single_test_error( japanext, - "bce", + Some("bce"), 0, "M03", 1, @@ -1893,83 +1893,83 @@ mod tests { single_test_error( japanext, - "reiwa", + Some("reiwa"), 2, "M13", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M13"))), ); - single_test_roundtrip(persian, "ap", 477, "M03", 1); - single_test_roundtrip(persian, "ap", 2083, "M07", 21); - single_test_roundtrip(persian, "ap", 1600, "M12", 20); + single_test_roundtrip(persian, Some("ap"), 477, "M03", 1); + single_test_roundtrip(persian, None, 2083, "M07", 21); + single_test_roundtrip(persian, Some("ap"), 1600, "M12", 20); single_test_error( persian, - "ap", + Some("ap"), 100, "M9", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M9"))), ); - single_test_roundtrip(hebrew, "hebrew", 5773, "M03", 1); - single_test_roundtrip(hebrew, "hebrew", 4993, "M07", 21); - single_test_roundtrip(hebrew, "hebrew", 5012, "M12", 20); + single_test_roundtrip(hebrew, Some("am"), 5773, "M03", 1); + single_test_roundtrip(hebrew, None, 4993, "M07", 21); + single_test_roundtrip(hebrew, Some("am"), 5012, "M12", 20); single_test_error( hebrew, - "hebrew", + Some("am"), 100, "M9", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M9"))), ); - single_test_roundtrip(roc, "roc", 10, "M05", 3); - single_test_roundtrip(roc, "roc-inverse", 15, "M01", 10); - single_test_roundtrip(roc, "roc", 100, "M10", 30); + single_test_roundtrip(roc, Some("minguo"), 10, "M05", 3); + single_test_roundtrip(roc, Some("minguo-qian"), 15, "M01", 10); + single_test_roundtrip(roc, None, 100, "M10", 30); - single_test_roundtrip(hijri_simulated, "ah", 477, "M03", 1); - single_test_roundtrip(hijri_simulated, "ah", 2083, "M07", 21); - single_test_roundtrip(hijri_simulated, "ah", 1600, "M12", 20); + single_test_roundtrip(hijri_simulated, Some("ah"), 477, "M03", 1); + single_test_roundtrip(hijri_simulated, None, 2083, "M07", 21); + single_test_roundtrip(hijri_simulated, Some("ah"), 1600, "M12", 20); single_test_error( hijri_simulated, - "ah", + Some("ah"), 100, "M9", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M9"))), ); - single_test_roundtrip(hijri_civil, "ah", 477, "M03", 1); - single_test_roundtrip(hijri_civil, "ah", 2083, "M07", 21); - single_test_roundtrip(hijri_civil, "ah", 1600, "M12", 20); + single_test_roundtrip(hijri_civil, Some("ah"), 477, "M03", 1); + single_test_roundtrip(hijri_civil, None, 2083, "M07", 21); + single_test_roundtrip(hijri_civil, Some("ah"), 1600, "M12", 20); single_test_error( hijri_civil, - "ah", + Some("ah"), 100, "M9", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M9"))), ); - single_test_roundtrip(hijri_umm_al_qura, "ah", 477, "M03", 1); - single_test_roundtrip(hijri_umm_al_qura, "ah", 2083, "M07", 21); - single_test_roundtrip(hijri_umm_al_qura, "ah", 1600, "M12", 20); + single_test_roundtrip(hijri_umm_al_qura, Some("ah"), 477, "M03", 1); + single_test_roundtrip(hijri_umm_al_qura, None, 2083, "M07", 21); + single_test_roundtrip(hijri_umm_al_qura, Some("ah"), 1600, "M12", 20); single_test_error( hijri_umm_al_qura, - "ah", + Some("ah"), 100, "M9", 1, DateError::UnknownMonthCode(MonthCode(tinystr!(4, "M9"))), ); - single_test_roundtrip(hijri_astronomical, "ah", 477, "M03", 1); - single_test_roundtrip(hijri_astronomical, "ah", 2083, "M07", 21); - single_test_roundtrip(hijri_astronomical, "ah", 1600, "M12", 20); + single_test_roundtrip(hijri_astronomical, Some("ah"), 477, "M03", 1); + single_test_roundtrip(hijri_astronomical, None, 2083, "M07", 21); + single_test_roundtrip(hijri_astronomical, Some("ah"), 1600, "M12", 20); single_test_error( hijri_astronomical, - "ah", + Some("ah"), 100, "M9", 1, diff --git a/components/calendar/src/cal/buddhist.rs b/components/calendar/src/cal/buddhist.rs index 2620e3f026c..37c913a59f5 100644 --- a/components/calendar/src/cal/buddhist.rs +++ b/components/calendar/src/cal/buddhist.rs @@ -42,7 +42,7 @@ const BUDDHIST_ERA_OFFSET: i32 = 543; /// /// # Era codes /// -/// This calendar uses a single era code, `buddhist` (alias `be`), with 1 B.E. being 543 BCE. +/// This calendar uses a single era code `be`, with 1 Buddhist Era being 543 BCE. Dates before this era use negative years. /// /// # Month codes /// @@ -61,7 +61,7 @@ impl Calendar for Buddhist { day: u8, ) -> Result { match era { - Some("buddhist" | "be") | None => {} + Some("be") | None => {} _ => return Err(DateError::UnknownEra), } let year = year - BUDDHIST_ERA_OFFSET; @@ -120,7 +120,7 @@ impl Calendar for Buddhist { types::YearInfo::new( buddhist_year, types::EraYear { - standard_era: tinystr!(16, "buddhist").into(), + standard_era: tinystr!(16, "be").into(), formatting_era: types::FormattingEra::Index(0, tinystr!(16, "BE")), era_year: buddhist_year, ambiguity: types::YearAmbiguity::CenturyRequired, diff --git a/components/calendar/src/cal/chinese.rs b/components/calendar/src/cal/chinese.rs index 9811be756ac..2e72ab2b5bb 100644 --- a/components/calendar/src/cal/chinese.rs +++ b/components/calendar/src/cal/chinese.rs @@ -57,7 +57,7 @@ use icu_provider::prelude::*; /// /// # Year and Era codes /// -/// This Calendar uses a single era code, `chinese`. +/// This calendar does not use era codes. /// /// Unlike the Gregorian calendar, the Chinese calendar does not traditionally count years in an infinitely /// increasing sequence. Instead, 10 "celestial stems" and 12 "terrestrial branches" are combined to form a @@ -182,7 +182,7 @@ impl Calendar for Chinese { }; match era { - Some("chinese") | None => {} + None => {} _ => return Err(DateError::UnknownEra), } diff --git a/components/calendar/src/cal/coptic.rs b/components/calendar/src/cal/coptic.rs index 2e1c54e5986..5fba1d050d3 100644 --- a/components/calendar/src/cal/coptic.rs +++ b/components/calendar/src/cal/coptic.rs @@ -35,7 +35,7 @@ use tinystr::tinystr; /// /// # Era codes /// -/// This calendar uses two era codes: `coptic-inverse`, and `coptic`, corresponding to the Before Diocletian and After Diocletian/Anno Martyrum +/// This calendar uses two era codes: `bd`, and `am`, corresponding to the Before Diocletian and After Diocletian/Anno Martyrum /// eras. 1 A.M. is equivalent to 284 C.E. /// /// # Month codes @@ -102,8 +102,8 @@ impl Calendar for Coptic { day: u8, ) -> Result { let year = match era { - Some("coptic") | None => year_check(year, 1..)?, - Some("coptic-inverse") => 1 - year_check(year, 1..)?, + Some("am") | None => year_check(year, 1..)?, + Some("bd") => 1 - year_check(year, 1..)?, Some(_) => return Err(DateError::UnknownEra), }; @@ -166,8 +166,8 @@ impl Calendar for Coptic { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "coptic").into(), - formatting_era: types::FormattingEra::Index(1, tinystr!(16, "AD")), + standard_era: tinystr!(16, "am").into(), + formatting_era: types::FormattingEra::Index(1, tinystr!(16, "AM")), era_year: year, ambiguity: types::YearAmbiguity::CenturyRequired, }, @@ -176,7 +176,7 @@ impl Calendar for Coptic { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "coptic-inverse").into(), + standard_era: tinystr!(16, "bd").into(), formatting_era: types::FormattingEra::Index(0, tinystr!(16, "BD")), era_year: 1 - year, ambiguity: types::YearAmbiguity::EraAndCenturyRequired, diff --git a/components/calendar/src/cal/dangi.rs b/components/calendar/src/cal/dangi.rs index 2039869e755..47cb4521184 100644 --- a/components/calendar/src/cal/dangi.rs +++ b/components/calendar/src/cal/dangi.rs @@ -68,8 +68,7 @@ use icu_provider::prelude::*; /// ``` /// # Era codes /// -/// This Calendar uses a single era code `dangi` based on the year -2332 ISO (2333 BCE) as year 1. Typically -/// years will be formatted using cyclic years and the related ISO year. +/// This calendar does not use era codes. /// /// # Month codes /// @@ -171,7 +170,7 @@ impl Calendar for Dangi { return Err(DateError::UnknownMonthCode(month_code)); }; match era { - Some("dangi") | None => {} + None => {} _ => return Err(DateError::UnknownEra), } diff --git a/components/calendar/src/cal/ethiopian.rs b/components/calendar/src/cal/ethiopian.rs index 0a592495ae6..6675b25f3c4 100644 --- a/components/calendar/src/cal/ethiopian.rs +++ b/components/calendar/src/cal/ethiopian.rs @@ -52,9 +52,9 @@ pub enum EthiopianEraStyle { /// /// # Era codes /// -/// This calendar always uses the `ethioaa` era (aliases `mundi`, `ethiopic-amete-alem`), where 1 Anno Mundi is 5493 BCE. +/// This calendar always uses the `aa` era, where 1 Amete Alem is 5493 BCE. Dates before this era use negative years. /// Dates before that use negative year numbers. -/// In the Amete Mihret scheme it uses the additional `ethiopic` era (alias `incar`), 1 Incarnation is 9 CE. +/// In the Amete Mihret scheme it uses the additional `am` era, 1 Amete Mihret is 9 CE. /// /// # Month codes /// @@ -120,16 +120,13 @@ impl Calendar for Ethiopian { day: u8, ) -> Result { let year = match (self.era_style(), era) { - (EthiopianEraStyle::AmeteMihret, Some("incar" | "ethiopic") | None) => { + (EthiopianEraStyle::AmeteMihret, Some("am") | None) => { year_check(year, 1..)? + INCARNATION_OFFSET } - (EthiopianEraStyle::AmeteMihret, Some("mundi" | "ethioaa" | "ethiopic-amete-alem")) => { + (EthiopianEraStyle::AmeteMihret, Some("aa")) => { year_check(year, ..=INCARNATION_OFFSET)? } - ( - EthiopianEraStyle::AmeteAlem, - Some("mundi" | "ethioaa" | "ethiopic-amete-alem") | None, - ) => year, + (EthiopianEraStyle::AmeteAlem, Some("aa") | None) => year, (_, Some(_)) => { return Err(DateError::UnknownEra); } @@ -203,8 +200,8 @@ impl Calendar for Ethiopian { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "ethioaa").into(), - formatting_era: types::FormattingEra::Index(0, tinystr!(16, "Anno Mundi")), + standard_era: tinystr!(16, "aa").into(), + formatting_era: types::FormattingEra::Index(0, tinystr!(16, "AA")), era_year: year, ambiguity: types::YearAmbiguity::CenturyRequired, }, @@ -213,8 +210,8 @@ impl Calendar for Ethiopian { types::YearInfo::new( year - INCARNATION_OFFSET, types::EraYear { - standard_era: tinystr!(16, "ethiopic").into(), - formatting_era: types::FormattingEra::Index(1, tinystr!(16, "Incarnation")), + standard_era: tinystr!(16, "am").into(), + formatting_era: types::FormattingEra::Index(1, tinystr!(16, "AM")), era_year: year - INCARNATION_OFFSET, ambiguity: types::YearAmbiguity::CenturyRequired, }, diff --git a/components/calendar/src/cal/gregorian.rs b/components/calendar/src/cal/gregorian.rs index d855919d42e..cb5f0419ac6 100644 --- a/components/calendar/src/cal/gregorian.rs +++ b/components/calendar/src/cal/gregorian.rs @@ -31,7 +31,7 @@ use tinystr::tinystr; /// /// # Era codes /// -/// This calendar uses two era codes: `gregory-inverse` (aliases `bce`, `bc`), and `gregory` (aliases `ce`, `ad`), corresponding to the BCE and CE eras. +/// This calendar uses two era codes: `bce` (alias `bc`), and `ce` (alias `ad`), corresponding to the BCE and CE eras. #[derive(Copy, Clone, Debug, Default)] #[allow(clippy::exhaustive_structs)] // this type is stable pub struct Gregorian; @@ -50,8 +50,8 @@ impl Calendar for Gregorian { day: u8, ) -> Result { let year = match era { - Some("gregory-inverse" | "bce" | "bc") | None => 1 - year_check(year, 1..)?, - Some("gregory" | "ad" | "ce") => year_check(year, 1..)?, + Some("bce" | "bc") | None => 1 - year_check(year, 1..)?, + Some("ad" | "ce") => year_check(year, 1..)?, Some(_) => return Err(DateError::UnknownEra), }; @@ -111,7 +111,7 @@ impl Calendar for Gregorian { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "gregory").into(), + standard_era: tinystr!(16, "ce").into(), formatting_era: types::FormattingEra::Index(1, tinystr!(16, "CE")), era_year: year, ambiguity: match year { @@ -126,7 +126,7 @@ impl Calendar for Gregorian { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "gregory-inverse").into(), + standard_era: tinystr!(16, "bce").into(), formatting_era: types::FormattingEra::Index(0, tinystr!(16, "BCE")), era_year: 1_i32.saturating_sub(year), ambiguity: types::YearAmbiguity::EraAndCenturyRequired, @@ -243,7 +243,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 1, - expected_era: Era(tinystr!(16, "gregory")), + expected_era: Era(tinystr!(16, "ce")), expected_month: 1, expected_day: 1, }, @@ -253,7 +253,7 @@ mod test { iso_month: 6, iso_day: 30, expected_year: 1, - expected_era: Era(tinystr!(16, "gregory")), + expected_era: Era(tinystr!(16, "ce")), expected_month: 6, expected_day: 30, }, @@ -263,7 +263,7 @@ mod test { iso_month: 2, iso_day: 29, expected_year: 4, - expected_era: Era(tinystr!(16, "gregory")), + expected_era: Era(tinystr!(16, "ce")), expected_month: 2, expected_day: 29, }, @@ -273,7 +273,7 @@ mod test { iso_month: 9, iso_day: 5, expected_year: 4, - expected_era: Era(tinystr!(16, "gregory")), + expected_era: Era(tinystr!(16, "ce")), expected_month: 9, expected_day: 5, }, @@ -283,7 +283,7 @@ mod test { iso_month: 3, iso_day: 1, expected_year: 100, - expected_era: Era(tinystr!(16, "gregory")), + expected_era: Era(tinystr!(16, "ce")), expected_month: 3, expected_day: 1, }, @@ -297,7 +297,7 @@ mod test { #[test] fn test_gregorian_bce() { // Tests that the Gregorian calendar gives the correct expected - // day, month, and year for negative years (BC/BCE/pre-gregory era) + // day, month, and year for negative years (BC/BCE era) let cases = [ TestCase { @@ -306,7 +306,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 1, - expected_era: Era(tinystr!(16, "gregory-inverse")), + expected_era: Era(tinystr!(16, "bce")), expected_month: 12, expected_day: 31, }, @@ -316,7 +316,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 1, - expected_era: Era(tinystr!(16, "gregory-inverse")), + expected_era: Era(tinystr!(16, "bce")), expected_month: 1, expected_day: 1, }, @@ -326,7 +326,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 2, - expected_era: Era(tinystr!(16, "gregory-inverse")), + expected_era: Era(tinystr!(16, "bce")), expected_month: 12, expected_day: 31, }, @@ -336,7 +336,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 5, - expected_era: Era(tinystr!(16, "gregory-inverse")), + expected_era: Era(tinystr!(16, "bce")), expected_month: 12, expected_day: 31, }, @@ -346,7 +346,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 5, - expected_era: Era(tinystr!(16, "gregory-inverse")), + expected_era: Era(tinystr!(16, "bce")), expected_month: 1, expected_day: 1, }, diff --git a/components/calendar/src/cal/hebrew.rs b/components/calendar/src/cal/hebrew.rs index 3688a7b1f4d..357dfb607b1 100644 --- a/components/calendar/src/cal/hebrew.rs +++ b/components/calendar/src/cal/hebrew.rs @@ -35,7 +35,7 @@ use calendrical_calculations::rata_die::RataDie; /// /// # Era codes /// -/// This calendar uses a single era code `hebrew` (alias `am`), Anno Mundi. +/// This calendar uses a single era code `am`, Anno Mundi. Dates before this era use negative years. /// /// # Month codes /// @@ -141,7 +141,7 @@ impl Calendar for Hebrew { day: u8, ) -> Result { match era { - Some("hebrew" | "am") | None => {} + Some("am") | None => {} _ => return Err(DateError::UnknownEra), } @@ -262,8 +262,8 @@ impl Calendar for Hebrew { types::YearInfo::new( date.0.year.value, types::EraYear { + standard_era: tinystr!(16, "am").into(), formatting_era: types::FormattingEra::Index(0, tinystr!(16, "AM")), - standard_era: tinystr!(16, "hebrew").into(), era_year: date.0.year.value, ambiguity: types::YearAmbiguity::CenturyRequired, }, @@ -489,15 +489,12 @@ mod tests { // Era year is accessible via the public getter. // TODO(#3962): Make extended year publicly accessible. assert_eq!(greg_date.inner.0 .0.year, -5000); - assert_eq!( - greg_date.year().standard_era().unwrap().0, - "gregory-inverse" - ); + assert_eq!(greg_date.year().standard_era().unwrap().0, "bce"); // In Gregorian, era year is 1 - extended year assert_eq!(greg_date.year().era_year().unwrap(), 5001); let hebr_date = greg_date.to_calendar(Hebrew); assert_eq!(hebr_date.inner.0.year.value, -1240); - assert_eq!(hebr_date.year().standard_era().unwrap().0, "hebrew"); + assert_eq!(hebr_date.year().standard_era().unwrap().0, "am"); // In Hebrew, there is no inverse era, so negative extended years are negative era years assert_eq!(hebr_date.year().era_year_or_related_iso(), -1240); } diff --git a/components/calendar/src/cal/hijri.rs b/components/calendar/src/cal/hijri.rs index 9cd5b512360..f68f83fc92e 100644 --- a/components/calendar/src/cal/hijri.rs +++ b/components/calendar/src/cal/hijri.rs @@ -33,12 +33,12 @@ use icu_provider::marker::ErasedMarker; use icu_provider::prelude::*; use tinystr::tinystr; -fn year_as_hijri(standard_era: tinystr::TinyStr16, year: i32) -> types::YearInfo { +fn year_as_hijri(year: i32) -> types::YearInfo { types::YearInfo::new( year, types::EraYear { + standard_era: types::Era(tinystr!(16, "ah")), formatting_era: types::FormattingEra::Index(0, tinystr!(16, "AH")), - standard_era: standard_era.into(), era_year: year, ambiguity: types::YearAmbiguity::CenturyRequired, }, @@ -49,7 +49,7 @@ fn year_as_hijri(standard_era: tinystr::TinyStr16, year: i32) -> types::YearInfo /// /// # Era codes /// -/// This calendar uses a single era code, `islamic-rgsa` (alias `ah`), Anno Hegirae. +/// This calendar uses a single era code `ah`, Anno Hegirae. Dates before this era use negative years. /// /// # Month codes /// @@ -80,7 +80,7 @@ impl HijriSimulatedLocation { /// /// # Era codes /// -/// This calendar uses a single era code, `islamic-umalqura` (alias `ah`), Anno Hegirae. +/// This calendar uses a single era code `ah`, Anno Hegirae. Dates before this era use negative years. /// /// # Month codes /// @@ -98,9 +98,7 @@ pub struct HijriUmmAlQura; /// /// # Era codes /// -/// In civil mode, this calendar uses a single era code, `islamic-civil` (aliases `ah`, `islamicc`), Anno Hegirae. -/// -/// In astronomical mode, it uses a single era code, `islamic-tbla` (alias `ah`), Anno Hegirae. +/// This calendar uses a single era code `ah`, Anno Hegirae. Dates before this era use negative years. /// /// # Month codes /// @@ -457,7 +455,7 @@ impl Calendar for HijriSimulated { } fn year(&self, date: &Self::DateInner) -> types::YearInfo { - year_as_hijri(tinystr!(16, "islamic-rgsa"), date.0.year.value) + year_as_hijri(date.0.year.value) } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { @@ -577,8 +575,6 @@ impl HijriSimulated { impl> Date { /// Construct new simulated Hijri Date. /// - /// Has no negative years, only era is the AH. - /// /// ```rust /// use icu::calendar::cal::HijriSimulated; /// use icu::calendar::Date; @@ -729,7 +725,7 @@ impl Calendar for HijriUmmAlQura { } fn year(&self, date: &Self::DateInner) -> types::YearInfo { - year_as_hijri(tinystr!(16, "islamic-umalqura"), date.0.year.value) + year_as_hijri(date.0.year.value) } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { @@ -1090,8 +1086,6 @@ impl HijriUmmAlQura { impl Date { /// Construct new Hijri Umm al-Qura Date. /// - /// Has no negative years, only era is the AH. - /// /// ```rust /// use icu::calendar::cal::HijriUmmAlQura; /// use icu::calendar::Date; @@ -1250,13 +1244,7 @@ impl Calendar for HijriTabular { } fn year(&self, date: &Self::DateInner) -> types::YearInfo { - year_as_hijri( - match self.epoch { - HijriTabularEpoch::Friday => tinystr!(16, "islamic-civil"), - HijriTabularEpoch::Thursday => tinystr!(16, "islamic-tbla"), - }, - date.0.year, - ) + year_as_hijri(date.0.year) } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { @@ -1283,8 +1271,6 @@ impl Calendar for HijriTabular { impl> Date { /// Construct new Tabular Hijri Date. /// - /// Has no negative years, only era is the AH. - /// /// ```rust /// use icu::calendar::cal::{HijriTabular, HijriTabularEpoch, HijriTabularLeapYears}; /// use icu::calendar::Date; diff --git a/components/calendar/src/cal/indian.rs b/components/calendar/src/cal/indian.rs index db4163abbc0..ed0b31805f8 100644 --- a/components/calendar/src/cal/indian.rs +++ b/components/calendar/src/cal/indian.rs @@ -31,7 +31,7 @@ use tinystr::tinystr; /// /// # Era codes /// -/// This calendar uses a single era code: `indian` (alias `saka`), with Saka 0 being 78 CE. Dates before this era use negative years. +/// This calendar uses a single era code: `saka`, with Saka 0 being 78 CE. Dates before this era use negative years. /// /// # Month codes /// @@ -100,7 +100,7 @@ impl Calendar for Indian { day: u8, ) -> Result { let year = match era { - Some("indian" | "saka") | None => year, + Some("saka") | None => year, Some(_) => return Err(DateError::UnknownEra), }; ArithmeticDate::new_from_codes(self, year, month_code, day).map(IndianDateInner) @@ -186,7 +186,7 @@ impl Calendar for Indian { date.0.year, types::EraYear { formatting_era: types::FormattingEra::Index(0, tinystr!(16, "Saka")), - standard_era: tinystr!(16, "indian").into(), + standard_era: tinystr!(16, "saka").into(), era_year: date.0.year, ambiguity: types::YearAmbiguity::CenturyRequired, }, diff --git a/components/calendar/src/cal/japanese.rs b/components/calendar/src/cal/japanese.rs index 2ff4809fa29..f040f8b709e 100644 --- a/components/calendar/src/cal/japanese.rs +++ b/components/calendar/src/cal/japanese.rs @@ -48,7 +48,7 @@ use tinystr::{tinystr, TinyStr16}; /// /// This calendar currently supports seven era codes. It supports the five post-Meiji eras /// (`meiji`, `taisho`, `showa`, `heisei`, `reiwa`), as well as using the Gregorian -/// `gregory-inverse`(aliases `bce`, `bc`) and `gregory` (aliases `ce`, `ad`) for dates before the Meiji era. +/// `bce` (alias `bc`), and `ce` (alias `ad`) for dates before the Meiji era. /// /// Future eras will also be added to this type when they are decided. /// @@ -78,7 +78,7 @@ pub struct Japanese { /// This calendar supports a large number of era codes. It supports the five post-Meiji eras /// (`meiji`, `taisho`, `showa`, `heisei`, `reiwa`). Pre-Meiji eras are represented /// with their names converted to lowercase ascii and followed by their start year. E.g. the *Ten'ō* -/// era (781 - 782 CE) has the code `teno-781`. The Gregorian `gregory-inverse` and `gregory` eras +/// era (781 - 782 CE) has the code `teno-781`. The Gregorian `bce` (alias `bc`), and `ce` (alias `ad`) /// are used for dates before the first known era era. /// /// @@ -187,7 +187,7 @@ impl Calendar for Japanese { return Err(DateError::UnknownMonthCode(month_code)); } - self.new_japanese_date_inner(era.unwrap_or("gregory"), year, month, day) + self.new_japanese_date_inner(era.unwrap_or("ce"), year, month, day) } fn from_rata_die(&self, rd: RataDie) -> Self::DateInner { @@ -536,9 +536,9 @@ impl Japanese { // In such a case, we instead fall back to Gregorian era codes if date < start { if date.year <= 0 { - (1 - date.year, tinystr!(16, "gregory-inverse")) + (1 - date.year, tinystr!(16, "bce")) } else { - (date.year, tinystr!(16, "gregory")) + (date.year, tinystr!(16, "ce")) } } else { (date.year - start.year + 1, era) @@ -639,12 +639,12 @@ impl Japanese { ) -> Result { let cal = Ref(self); let era = match era { - "gregory" | "ce" | "ad" => { + "ce" | "ad" => { return Ok(Date::try_new_gregorian(year_check(year, 1..)?, month, day)? .to_calendar(cal) .inner); } - "gregory-inverse" | "bce" | "bc" => { + "bce" | "bc" => { return Ok( Date::try_new_gregorian(1 - year_check(year, 1..)?, month, day)? .to_calendar(cal) @@ -875,15 +875,15 @@ mod tests { single_test_error(calendar, "hakuho-672", 4, 3, 1, DateError::UnknownEra); // handle bce/ce - single_test_roundtrip(calendar, "gregory-inverse", 100, 3, 1); - single_test_roundtrip(calendar, "gregory-inverse", 1, 3, 1); - single_test_roundtrip(calendar, "gregory", 1, 3, 1); - single_test_roundtrip(calendar, "gregory", 100, 3, 1); - single_test_roundtrip_ext(calendar_ext, "gregory", 100, 3, 1); - single_test_roundtrip(calendar, "gregory", 1000, 3, 1); + single_test_roundtrip(calendar, "bce", 100, 3, 1); + single_test_roundtrip(calendar, "bce", 1, 3, 1); + single_test_roundtrip(calendar, "ce", 1, 3, 1); + single_test_roundtrip(calendar, "ce", 100, 3, 1); + single_test_roundtrip_ext(calendar_ext, "ce", 100, 3, 1); + single_test_roundtrip(calendar, "ce", 1000, 3, 1); single_test_error( calendar, - "gregory", + "ce", 0, 3, 1, @@ -896,7 +896,7 @@ mod tests { ); single_test_error( calendar, - "gregory-inverse", + "bce", -1, 3, 1, @@ -908,27 +908,11 @@ mod tests { }, ); - // handle the cases where gregory-inverse/gregory get adjusted to different eras - // single_test_gregorian_roundtrip(calendar, "gregory", 2021, 3, 1, "reiwa", 3); - single_test_gregorian_roundtrip_ext(calendar_ext, "gregory", 1000, 3, 1, "choho-999", 2); - single_test_gregorian_roundtrip_ext( - calendar_ext, - "gregory", - 749, - 5, - 10, - "tenpyokampo-749", - 1, - ); - single_test_gregorian_roundtrip_ext( - calendar_ext, - "gregory-inverse", - 10, - 3, - 1, - "gregory-inverse", - 10, - ); + // handle the cases where bce/ce get adjusted to different eras + // single_test_gregorian_roundtrip(calendar, "ce", 2021, 3, 1, "reiwa", 3); + single_test_gregorian_roundtrip_ext(calendar_ext, "ce", 1000, 3, 1, "choho-999", 2); + single_test_gregorian_roundtrip_ext(calendar_ext, "ce", 749, 5, 10, "tenpyokampo-749", 1); + single_test_gregorian_roundtrip_ext(calendar_ext, "bce", 10, 3, 1, "bce", 10); // There were multiple eras in this year // This one is from Apr 14 to July 2 diff --git a/components/calendar/src/cal/julian.rs b/components/calendar/src/cal/julian.rs index 40c2bf0d0ef..82c9739c7e0 100644 --- a/components/calendar/src/cal/julian.rs +++ b/components/calendar/src/cal/julian.rs @@ -35,7 +35,7 @@ use tinystr::tinystr; /// /// # Era codes /// -/// This calendar uses two era codes: `julian-inverse` (aliases `bce`, `bc`), and `julian` (aliases `ce`, `ad`), corresponding to the BCE/BC and CE/AD eras +/// This calendar uses two era codes: `bce` (alias `bc`), and `ce` (alias `ad`), corresponding to the BCE and CE eras. /// /// # Month codes /// @@ -93,8 +93,8 @@ impl Calendar for Julian { day: u8, ) -> Result { let year = match era { - Some("julian" | "ce" | "ad") | None => year_check(year, 1..)?, - Some("julian-inverse" | "bce" | "bc") => 1 - year_check(year, 1..)?, + Some("ce" | "ad") | None => year_check(year, 1..)?, + Some("bce" | "bc") => 1 - year_check(year, 1..)?, Some(_) => return Err(DateError::UnknownEra), }; @@ -159,7 +159,7 @@ impl Calendar for Julian { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "julian").into(), + standard_era: tinystr!(16, "ad").into(), formatting_era: types::FormattingEra::Index(1, tinystr!(16, "AD")), era_year: year, ambiguity: types::YearAmbiguity::CenturyRequired, @@ -169,7 +169,7 @@ impl Calendar for Julian { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "julian-inverse").into(), + standard_era: tinystr!(16, "bc").into(), formatting_era: types::FormattingEra::Index(0, tinystr!(16, "BC")), era_year: 1_i32.saturating_sub(year), ambiguity: types::YearAmbiguity::EraAndCenturyRequired, @@ -336,7 +336,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 1, - expected_era: Era(tinystr!(16, "julian")), + expected_era: Era(tinystr!(16, "ad")), expected_month: 1, expected_day: 3, }, @@ -346,7 +346,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 1, - expected_era: Era(tinystr!(16, "julian")), + expected_era: Era(tinystr!(16, "ad")), expected_month: 1, expected_day: 2, }, @@ -356,7 +356,7 @@ mod test { iso_month: 12, iso_day: 30, expected_year: 1, - expected_era: Era(tinystr!(16, "julian")), + expected_era: Era(tinystr!(16, "ad")), expected_month: 1, expected_day: 1, }, @@ -366,7 +366,7 @@ mod test { iso_month: 12, iso_day: 29, expected_year: 1, - expected_era: Era(tinystr!(16, "julian-inverse")), + expected_era: Era(tinystr!(16, "bc")), expected_month: 12, expected_day: 31, }, @@ -376,7 +376,7 @@ mod test { iso_month: 12, iso_day: 28, expected_year: 1, - expected_era: Era(tinystr!(16, "julian-inverse")), + expected_era: Era(tinystr!(16, "bc")), expected_month: 12, expected_day: 30, }, @@ -386,7 +386,7 @@ mod test { iso_month: 12, iso_day: 30, expected_year: 1, - expected_era: Era(tinystr!(16, "julian-inverse")), + expected_era: Era(tinystr!(16, "bc")), expected_month: 1, expected_day: 1, }, @@ -396,7 +396,7 @@ mod test { iso_month: 12, iso_day: 29, expected_year: 2, - expected_era: Era(tinystr!(16, "julian-inverse")), + expected_era: Era(tinystr!(16, "bc")), expected_month: 12, expected_day: 31, }, @@ -406,7 +406,7 @@ mod test { iso_month: 12, iso_day: 30, expected_year: 4, - expected_era: Era(tinystr!(16, "julian-inverse")), + expected_era: Era(tinystr!(16, "bc")), expected_month: 1, expected_day: 1, }, @@ -416,7 +416,7 @@ mod test { iso_month: 12, iso_day: 29, expected_year: 5, - expected_era: Era(tinystr!(16, "julian-inverse")), + expected_era: Era(tinystr!(16, "bc")), expected_month: 12, expected_day: 31, }, diff --git a/components/calendar/src/cal/persian.rs b/components/calendar/src/cal/persian.rs index ea4725b7ca8..e715f5c1a0c 100644 --- a/components/calendar/src/cal/persian.rs +++ b/components/calendar/src/cal/persian.rs @@ -32,7 +32,7 @@ use calendrical_calculations::rata_die::RataDie; /// /// # Era codes /// -/// This calendar uses a single era code: `persian` (alias `ap`), with AP starting the year of the Hijra. +/// This calendar uses a single era code `ap` (aliases `sh`, `hs`), with Anno Persico/Anno Persarum starting the year of the Hijra. Dates before this era use negative years. /// /// # Month codes /// @@ -94,7 +94,7 @@ impl Calendar for Persian { day: u8, ) -> Result { let year = match era { - Some("persian" | "ap") | None => year, + Some("ap" | "sh" | "hs") | None => year, Some(_) => return Err(DateError::UnknownEra), }; @@ -160,8 +160,8 @@ impl Calendar for Persian { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "persian").into(), - formatting_era: types::FormattingEra::Index(0, tinystr!(16, "AH")), + standard_era: tinystr!(16, "ap").into(), + formatting_era: types::FormattingEra::Index(0, tinystr!(16, "AP")), era_year: year, ambiguity: types::YearAmbiguity::CenturyRequired, }, diff --git a/components/calendar/src/cal/roc.rs b/components/calendar/src/cal/roc.rs index 43629faced8..d1826bbb62c 100644 --- a/components/calendar/src/cal/roc.rs +++ b/components/calendar/src/cal/roc.rs @@ -39,8 +39,8 @@ const ROC_ERA_OFFSET: i32 = 1911; /// /// # Era codes /// -/// This calendar uses two era codes: `roc` (alias `minguo`), corresponding to years in the 民國 (minguo) era (CE year 1912 and -/// after), and `roc-inverse` (alias `before-roc`), corresponding to years before the 民國 (minguo) era (CE year 1911 and before). +/// This calendar uses two era codes: `minguo`, corresponding to years in the 民國 era (CE year 1912 and +/// after), and `minguo-qian`, corresponding to years before the 民國 era (CE year 1911 and before). /// /// /// # Month codes @@ -65,8 +65,8 @@ impl Calendar for Roc { day: u8, ) -> Result { let year = match era { - Some("roc" | "minguo") | None => ROC_ERA_OFFSET + year_check(year, 1..)?, - Some("roc-inverse" | "before-roc") => ROC_ERA_OFFSET + 1 - year_check(year, 1..)?, + Some("minguo") | None => ROC_ERA_OFFSET + year_check(year, 1..)?, + Some("minguo-qian") => ROC_ERA_OFFSET + 1 - year_check(year, 1..)?, Some(_) => return Err(DateError::UnknownEra), }; @@ -129,8 +129,8 @@ impl Calendar for Roc { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "roc").into(), - formatting_era: types::FormattingEra::Index(1, tinystr!(16, "ROC")), + standard_era: tinystr!(16, "minguo").into(), + formatting_era: types::FormattingEra::Index(1, tinystr!(16, "min guo")), era_year: year.saturating_sub(ROC_ERA_OFFSET), ambiguity: types::YearAmbiguity::CenturyRequired, }, @@ -139,8 +139,8 @@ impl Calendar for Roc { types::YearInfo::new( year, types::EraYear { - standard_era: tinystr!(16, "roc-inverse").into(), - formatting_era: types::FormattingEra::Index(0, tinystr!(16, "B. ROC")), + standard_era: tinystr!(16, "minguo-qian").into(), + formatting_era: types::FormattingEra::Index(0, tinystr!(16, "min guo qian")), era_year: (ROC_ERA_OFFSET + 1).saturating_sub(year), ambiguity: types::YearAmbiguity::EraAndCenturyRequired, }, @@ -184,7 +184,7 @@ impl Date { /// let date_roc = Date::try_new_roc(1, 2, 3) /// .expect("Failed to initialize ROC Date instance."); /// - /// assert_eq!(date_roc.year().standard_era().unwrap().0, tinystr!(16, "roc")); + /// assert_eq!(date_roc.year().standard_era().unwrap().0, tinystr!(16, "minguo")); /// assert_eq!(date_roc.year().era_year_or_related_iso(), 1, "ROC year check failed!"); /// assert_eq!(date_roc.month().ordinal, 2, "ROC month check failed!"); /// assert_eq!(date_roc.day_of_month().0, 3, "ROC day of month check failed!"); @@ -264,7 +264,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 1, - expected_era: Era(tinystr!(16, "roc")), + expected_era: Era(tinystr!(16, "minguo")), expected_month: 1, expected_day: 1, }, @@ -274,7 +274,7 @@ mod test { iso_month: 2, iso_day: 29, expected_year: 1, - expected_era: Era(tinystr!(16, "roc")), + expected_era: Era(tinystr!(16, "minguo")), expected_month: 2, expected_day: 29, }, @@ -284,7 +284,7 @@ mod test { iso_month: 6, iso_day: 30, expected_year: 2, - expected_era: Era(tinystr!(16, "roc")), + expected_era: Era(tinystr!(16, "minguo")), expected_month: 6, expected_day: 30, }, @@ -294,7 +294,7 @@ mod test { iso_month: 7, iso_day: 13, expected_year: 112, - expected_era: Era(tinystr!(16, "roc")), + expected_era: Era(tinystr!(16, "minguo")), expected_month: 7, expected_day: 13, }, @@ -318,7 +318,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 1, - expected_era: Era(tinystr!(16, "roc-inverse")), + expected_era: Era(tinystr!(16, "minguo-qian")), expected_month: 12, expected_day: 31, }, @@ -328,7 +328,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 1, - expected_era: Era(tinystr!(16, "roc-inverse")), + expected_era: Era(tinystr!(16, "minguo-qian")), expected_month: 1, expected_day: 1, }, @@ -338,7 +338,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 2, - expected_era: Era(tinystr!(16, "roc-inverse")), + expected_era: Era(tinystr!(16, "minguo-qian")), expected_month: 12, expected_day: 31, }, @@ -348,7 +348,7 @@ mod test { iso_month: 2, iso_day: 29, expected_year: 4, - expected_era: Era(tinystr!(16, "roc-inverse")), + expected_era: Era(tinystr!(16, "minguo-qian")), expected_month: 2, expected_day: 29, }, @@ -358,7 +358,7 @@ mod test { iso_month: 1, iso_day: 1, expected_year: 1911, - expected_era: Era(tinystr!(16, "roc-inverse")), + expected_era: Era(tinystr!(16, "minguo-qian")), expected_month: 1, expected_day: 1, }, @@ -368,7 +368,7 @@ mod test { iso_month: 12, iso_day: 31, expected_year: 1912, - expected_era: Era(tinystr!(16, "roc-inverse")), + expected_era: Era(tinystr!(16, "minguo-qian")), expected_month: 12, expected_day: 31, }, diff --git a/provider/source/src/calendar/eras.rs b/provider/source/src/calendar/eras.rs index 99c819f8d36..f71c9d620aa 100644 --- a/provider/source/src/calendar/eras.rs +++ b/provider/source/src/calendar/eras.rs @@ -504,25 +504,26 @@ fn test_calendar_eras() { let in_era = in_era_iso.to_calendar(cal); let not_in_era = not_in_era_iso.to_calendar(cal); + // TODO: reenable with CLDR-48 // Check that code and aliases produce identical results - for era in era - .aliases - .as_deref() - .into_iter() - .flat_map(|s| s.split(' ')) - .chain(era.code.as_deref()) - { - assert_eq!( - Date::try_new_from_codes( - Some(era), - in_era.year().era_year_or_related_iso(), - in_era.month().standard_code, - in_era.day_of_month().0, - cal, - ), - Ok(in_era) - ); - } + // for era in era + // .aliases + // .as_deref() + // .into_iter() + // .flat_map(|s| s.split(' ')) + // .chain(era.code.as_deref()) + // { + // assert_eq!( + // Date::try_new_from_codes( + // Some(era), + // in_era.year().era_year_or_related_iso(), + // in_era.month().standard_code, + // in_era.day_of_month().0, + // cal, + // ), + // Ok(in_era) + // ); + // } // Unless this is the first era and it's not an inverse era, check that the // not_in_era date is in a different era @@ -542,10 +543,11 @@ fn test_calendar_eras() { assert_eq!(i.to_string(), idx); } - // Check that the correct era code is returned - if let Some(code) = era.code.as_deref() { - assert_eq!(in_era.year().standard_era().unwrap().0, code); - } + // TODO: reenable with CLDR-48 + // // Check that the correct era code is returned + // if let Some(code) = era.code.as_deref() { + // assert_eq!(in_era.year().standard_era().unwrap().0, code); + // } // Check that the start/end date uses year 1, and minimal/maximal month/day assert_eq!(in_era.year().era_year_or_related_iso(), 1);