From 80864531a6e3a1793c5520deab31707615645ba1 Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Wed, 20 Nov 2024 14:40:01 -0800 Subject: [PATCH] format_any_calendar --- README.md | 2 +- components/datetime/README.md | 2 +- components/datetime/src/combo.rs | 4 ++-- components/datetime/src/dynamic.rs | 2 +- components/datetime/src/fieldsets.rs | 6 +++--- components/datetime/src/lib.rs | 2 +- components/datetime/src/neo.rs | 10 +++++----- components/datetime/tests/datetime.rs | 2 +- ffi/capi/src/datetime_formatter.rs | 12 ++++++------ ffi/capi/src/zoned_formatter.rs | 4 ++-- ffi/capi/tests/missing_apis.txt | 2 +- tutorials/data_management.md | 4 ++-- tutorials/intro.md | 2 +- tutorials/intro_interactive.md | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 3ea72f2dc4c..b89e94f0236 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ let dtf = DateTimeFormatter::try_new( let date = DateTime::try_new_iso(2020, 9, 12, 12, 35, 0).expect("datetime should be valid"); let date = date.to_any(); -let formatted_date = dtf.format_converted(&date).to_string_lossy(); +let formatted_date = dtf.format_any_calendar(&date).to_string_lossy(); assert_eq!( formatted_date, "12 de septiembre de 2020, 12:35:00" diff --git a/components/datetime/README.md b/components/datetime/README.md index 84a8e5235f4..7d739420374 100644 --- a/components/datetime/README.md +++ b/components/datetime/README.md @@ -64,7 +64,7 @@ let dtf = DateTimeFormatter::try_new(locale.into(), field_set).unwrap(); // Format something: let datetime = DateTime::try_new_iso(2025, 1, 15, 16, 9, 35).unwrap(); -let formatted_date = dtf.format_converted(&datetime); +let formatted_date = dtf.format_any_calendar(&datetime); assert_try_writeable_eq!(formatted_date, "15 de ene de 2025, 4:09 p. m."); ``` diff --git a/components/datetime/src/combo.rs b/components/datetime/src/combo.rs index d01d212cfdd..594829c2750 100644 --- a/components/datetime/src/combo.rs +++ b/components/datetime/src/combo.rs @@ -45,7 +45,7 @@ use crate::{provider::neo::*, scaffold::*}; /// .unwrap(); /// /// assert_try_writeable_eq!( -/// formatter.format_converted(&zdt), +/// formatter.format_any_calendar(&zdt), /// "Fri, 3:44 PM Los Angeles Time" /// ); /// ``` @@ -102,7 +102,7 @@ use crate::{provider::neo::*, scaffold::*}; /// .unwrap(); /// /// assert_try_writeable_eq!( -/// formatter.format_converted(&zdt), +/// formatter.format_any_calendar(&zdt), /// "October 18, 2024 PT" /// ); /// ``` diff --git a/components/datetime/src/dynamic.rs b/components/datetime/src/dynamic.rs index a04dfbdb30c..368b5d43f1b 100644 --- a/components/datetime/src/dynamic.rs +++ b/components/datetime/src/dynamic.rs @@ -50,7 +50,7 @@ //! let results = [true, false].map(get_field_set).map(|field_set| { //! DateTimeFormatter::try_new(locale!("en-US").into(), field_set).unwrap() //! }).map(|formatter| { -//! formatter.format_converted(&datetime).try_write_to_string().unwrap().into_owned() +//! formatter.format_any_calendar(&datetime).try_write_to_string().unwrap().into_owned() //! }); //! //! assert_eq!(results, ["Jan 15, 4:00 PM", "Jan 15"]) diff --git a/components/datetime/src/fieldsets.rs b/components/datetime/src/fieldsets.rs index dc462ba4158..0c1f7382966 100644 --- a/components/datetime/src/fieldsets.rs +++ b/components/datetime/src/fieldsets.rs @@ -380,7 +380,7 @@ macro_rules! impl_date_or_calendar_period_marker { /// let dt = Date::try_new_iso(2024, 5, 17).unwrap(); /// /// assert_try_writeable_eq!( - /// fmt.format_converted(&dt), + /// fmt.format_any_calendar(&dt), #[doc = concat!(" \"", $sample, "\"")] /// ); /// ``` @@ -526,7 +526,7 @@ macro_rules! impl_date_marker { /// let dt = DateTime::try_new_iso(2024, 5, 17, 15, 47, 50).unwrap(); /// /// assert_try_writeable_eq!( - /// fmt.format_converted(&dt), + /// fmt.format_any_calendar(&dt), #[doc = concat!(" \"", $sample_time, "\"")] /// ); /// ``` @@ -922,7 +922,7 @@ macro_rules! impl_zoneddatetime_marker { /// let mut dtz = IxdtfParser::new().try_from_str("2024-05-17T15:47:50+01:00[Europe/London]").unwrap(); /// /// assert_try_writeable_eq!( - /// fmt.format_converted(&dtz), + /// fmt.format_any_calendar(&dtz), #[doc = concat!(" \"", $sample, "\"")] /// ); /// ``` diff --git a/components/datetime/src/lib.rs b/components/datetime/src/lib.rs index 678482da35c..7a88cae5e14 100644 --- a/components/datetime/src/lib.rs +++ b/components/datetime/src/lib.rs @@ -64,7 +64,7 @@ //! //! // Format something: //! let datetime = DateTime::try_new_iso(2025, 1, 15, 16, 9, 35).unwrap(); -//! let formatted_date = dtf.format_converted(&datetime); +//! let formatted_date = dtf.format_any_calendar(&datetime); //! //! assert_try_writeable_eq!(formatted_date, "15 de ene de 2025, 4:09 p. m."); //! ``` diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index bd1e676fb13..68c97f49232 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -400,7 +400,7 @@ where /// let datetime = DateTime::try_new_iso(2024, 5, 8, 0, 0, 0).unwrap(); /// /// assert_try_writeable_eq!( - /// formatter.format_converted(&datetime), + /// formatter.format_any_calendar(&datetime), /// "30 Nisan 5784" /// ); /// ``` @@ -599,7 +599,7 @@ where /// let date = Date::try_new_roc(113, 5, 8).unwrap(); /// /// assert_try_writeable_eq!( - /// formatter.format_converted(&date), + /// formatter.format_any_calendar(&date), /// "30 Nisan 5784" /// ); /// ``` @@ -620,9 +620,9 @@ where /// /// // the trait `GetField` /// // is not implemented for `icu::icu_calendar::Time` - /// formatter.format_converted(&Time::try_new(0, 0, 0, 0).unwrap()); + /// formatter.format_any_calendar(&Time::try_new(0, 0, 0, 0).unwrap()); /// ``` - pub fn format_converted<'a, I>(&'a self, datetime: &I) -> FormattedDateTime<'a> + pub fn format_any_calendar<'a, I>(&'a self, datetime: &I) -> FormattedDateTime<'a> where I: ?Sized + ConvertCalendar, I::Converted<'a>: Sized + AllInputMarkers, @@ -666,7 +666,7 @@ impl FixedCalendarDateTimeFormatter( description ); - let actual3 = any_dtf.format_converted(&iso_any_input); + let actual3 = any_dtf.format_any_calendar(&iso_any_input); assert_try_writeable_eq!( actual3, output_value.expectation(), diff --git a/ffi/capi/src/datetime_formatter.rs b/ffi/capi/src/datetime_formatter.rs index 9534a92ac44..0a42e2b3d09 100644 --- a/ffi/capi/src/datetime_formatter.rs +++ b/ffi/capi/src/datetime_formatter.rs @@ -207,7 +207,7 @@ pub mod ffi { value: &Date, write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), DateTimeFormatError> { - let _lossy = self.0.format_converted(&value.0).try_write_to(write); + let _lossy = self.0.format_any_calendar(&value.0).try_write_to(write); Ok(()) } @@ -220,7 +220,7 @@ pub mod ffi { write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), DateTimeFormatError> { let any = value.0.to_any(); - let _lossy = self.0.format_converted(&any).try_write_to(write); + let _lossy = self.0.format_any_calendar(&any).try_write_to(write); Ok(()) } @@ -230,7 +230,7 @@ pub mod ffi { value: &DateTime, write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), DateTimeFormatError> { - let _lossy = self.0.format_converted(&value.0).try_write_to(write); + let _lossy = self.0.format_any_calendar(&value.0).try_write_to(write); Ok(()) } @@ -243,7 +243,7 @@ pub mod ffi { write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), DateTimeFormatError> { let any = value.0.to_any(); - let _lossy = self.0.format_converted(&any).try_write_to(write); + let _lossy = self.0.format_any_calendar(&any).try_write_to(write); Ok(()) } } @@ -282,7 +282,7 @@ pub mod ffi { value: &DateTime, write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), DateTimeFormatError> { - let _lossy = self.0.format_converted(&value.0).try_write_to(write); + let _lossy = self.0.format_any_calendar(&value.0).try_write_to(write); Ok(()) } @@ -295,7 +295,7 @@ pub mod ffi { write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), DateTimeFormatError> { let any = value.0.to_any(); - let _lossy = self.0.format_converted(&any).try_write_to(write); + let _lossy = self.0.format_any_calendar(&any).try_write_to(write); Ok(()) } } diff --git a/ffi/capi/src/zoned_formatter.rs b/ffi/capi/src/zoned_formatter.rs index 38508f39d38..f8bd6b05abd 100644 --- a/ffi/capi/src/zoned_formatter.rs +++ b/ffi/capi/src/zoned_formatter.rs @@ -127,7 +127,7 @@ pub mod ffi { .ok_or(DateTimeFormatError::ZoneInfoMissingFields)?, ), }; - let _lossy = self.0.format_converted(&zdt).try_write_to(write); + let _lossy = self.0.format_any_calendar(&zdt).try_write_to(write); Ok(()) } @@ -147,7 +147,7 @@ pub mod ffi { .at_time((datetime.0.date, datetime.0.time)) .with_zone_variant(time_zone.zone_variant.unwrap_or(ZoneVariant::Standard)), }; - let _lossy = self.0.format_converted(&zdt).try_write_to(write); + let _lossy = self.0.format_any_calendar(&zdt).try_write_to(write); Ok(()) } } diff --git a/ffi/capi/tests/missing_apis.txt b/ffi/capi/tests/missing_apis.txt index 0fe408aa686..1768a3f7841 100644 --- a/ffi/capi/tests/missing_apis.txt +++ b/ffi/capi/tests/missing_apis.txt @@ -22,7 +22,7 @@ icu::calendar::types::YearAmbiguity#Enum icu::calendar::types::YearInfo::year_ambiguity#FnInStruct icu::collator::CollatorPreferences::extend#FnInStruct icu::datetime::DateTimeFormatter#Struct -icu::datetime::DateTimeFormatter::format_converted#FnInStruct +icu::datetime::DateTimeFormatter::format_any_calendar#FnInStruct icu::datetime::DateTimeFormatter::format_same_calendar#FnInStruct icu::datetime::DateTimeFormatter::try_into_typed_formatter#FnInStruct icu::datetime::DateTimeFormatter::try_new#FnInStruct diff --git a/tutorials/data_management.md b/tutorials/data_management.md index 764d85d53bd..6b69cc12613 100644 --- a/tutorials/data_management.md +++ b/tutorials/data_management.md @@ -116,7 +116,7 @@ fn main() { .expect("datetime should be valid"); let date = date.to_any(); - let formatted_date = dtf.format_converted(&date).to_string_lossy(); + let formatted_date = dtf.format_any_calendar(&date).to_string_lossy(); println!("📅: {}", formatted_date); } @@ -182,7 +182,7 @@ fn main() { .expect("datetime should be valid"); let date = date.to_any(); - let formatted_date = dtf.format_converted(&date).to_string_lossy(); + let formatted_date = dtf.format_any_calendar(&date).to_string_lossy(); println!("📅: {}", formatted_date); } diff --git a/tutorials/intro.md b/tutorials/intro.md index 60aa28643cc..ea6fb365710 100644 --- a/tutorials/intro.md +++ b/tutorials/intro.md @@ -126,7 +126,7 @@ fn main() { // For smaller codesize you can use FixedCalendarDateTimeFormatter with a DateTime let date = date.to_any(); - let formatted_date = dtf.format_converted(&date).to_string_lossy(); + let formatted_date = dtf.format_any_calendar(&date).to_string_lossy(); println!("📅: {}", formatted_date); } diff --git a/tutorials/intro_interactive.md b/tutorials/intro_interactive.md index abd4e84f9d1..025814793f8 100644 --- a/tutorials/intro_interactive.md +++ b/tutorials/intro_interactive.md @@ -171,7 +171,7 @@ let date_formatter = DateTimeFormatter::try_new( println!( "Date: {}", date_formatter - .format_converted(&iso_date.to_any()).to_string_lossy() + .format_any_calendar(&iso_date.to_any()).to_string_lossy() ); ```