From 57e9d59ec7396f5545e2f0e2ebfc608b48470a4c Mon Sep 17 00:00:00 2001 From: Andrew Cupps <91998663+atcupps@users.noreply.github.com> Date: Tue, 8 Aug 2023 18:53:26 -0700 Subject: [PATCH] Resolve follow-up comments to #3760 (#3818) * Docs for `U` and `r` * Delete empty test and add todo * Remove old code and empty era check * Add todo --- components/datetime/src/fields/symbols.rs | 4 ++-- components/datetime/src/format/datetime.rs | 5 +---- components/datetime/src/provider/date_time.rs | 3 --- provider/datagen/src/transform/cldr/datetime/mod.rs | 1 - provider/datagen/src/transform/cldr/datetime/symbols.rs | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/components/datetime/src/fields/symbols.rs b/components/datetime/src/fields/symbols.rs index b505e59622c..c1f59058f13 100644 --- a/components/datetime/src/fields/symbols.rs +++ b/components/datetime/src/fields/symbols.rs @@ -448,9 +448,9 @@ field_type! ( /// /// This works for “week of year” based calendars in which the year transition occurs on a week boundary; may differ from calendar year [`Year::Calendar`] near a year transition. This numeric year designation is used in conjunction with [`Week::WeekOfYear`], but can be used in non-Gregorian based calendar systems where week date processing is desired. The field length is interpreted in the same way as for [`Year::Calendar`]. 'Y' => WeekOf = 1, - /// TODO: Docs + /// Field symbol for cyclic year; used in calendars where years are tracked in cycles, such as the Chinese or Dangi calendars. 'U' => Cyclic = 2, - /// TODO: Docs + /// Field symbol for related ISO; some calendars which use different year numbering than ISO, or no year numbering, may express years in an ISO year corresponding to a calendar year. 'r' => RelatedIso = 3, }; Numeric; diff --git a/components/datetime/src/format/datetime.rs b/components/datetime/src/format/datetime.rs index 94b706cf19e..ec3fe9fddbb 100644 --- a/components/datetime/src/format/datetime.rs +++ b/components/datetime/src/format/datetime.rs @@ -300,7 +300,7 @@ where .ok_or(Error::MissingDateSymbols)? .get_symbols_for_month(month, length)?; w.write_str(symbols.get(code).ok_or(Error::MissingMonthSymbol(code))?)?; - w.write_str("(leap)")?; + w.write_str("(leap)")?; // This is temporary; TODO(#3766) add support for leap months } } }, @@ -640,7 +640,4 @@ mod tests { } } } - - #[test] - fn test_year_formatting() {} } diff --git a/components/datetime/src/provider/date_time.rs b/components/datetime/src/provider/date_time.rs index 707d28d7c55..f05e521c150 100644 --- a/components/datetime/src/provider/date_time.rs +++ b/components/datetime/src/provider/date_time.rs @@ -406,9 +406,6 @@ impl<'data> DateSymbols<'data> for provider::calendar::DateSymbolsV1<'data> { fields::FieldLength::Narrow => &self.eras.narrow, _ => &self.eras.abbr, }; - if symbols.is_empty() { - return ""; // If symbols is empty, this calendar doesn't use eras (ex. Chinese) - } symbols .get(era_code.0.as_str().into()) .unwrap_or(&era_code.0) diff --git a/provider/datagen/src/transform/cldr/datetime/mod.rs b/provider/datagen/src/transform/cldr/datetime/mod.rs index ff382531af2..56373a2a576 100644 --- a/provider/datagen/src/transform/cldr/datetime/mod.rs +++ b/provider/datagen/src/transform/cldr/datetime/mod.rs @@ -103,7 +103,6 @@ macro_rules! impl_data_provider { let mundi_name = ethioaa_data .eras - // .ok_or_else(|| DataError::custom("Could not find eras"))? .names .get("0") .expect("ethiopic-amete-alem calendar must have 0 era"); diff --git a/provider/datagen/src/transform/cldr/datetime/symbols.rs b/provider/datagen/src/transform/cldr/datetime/symbols.rs index a47003e83bf..9af017450e4 100644 --- a/provider/datagen/src/transform/cldr/datetime/symbols.rs +++ b/provider/datagen/src/transform/cldr/datetime/symbols.rs @@ -64,7 +64,7 @@ fn get_month_code_map(calendar: &str) -> &'static [TinyStr4] { "gregory" | "buddhist" | "japanese" | "japanext" | "indian" | "persian" | "roc" => { &SOLAR_MONTH_CODES[0..12] } - "coptic" | "ethiopic" | "chinese" => SOLAR_MONTH_CODES, + "coptic" | "ethiopic" | "chinese" => SOLAR_MONTH_CODES, // TODO(#3766): Fix leap month formatting _ => panic!("Month map unknown for {calendar}"), } }