Skip to content

Commit

Permalink
format_any_calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Nov 20, 2024
1 parent 0a6da33 commit 8086453
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/datetime/src/combo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/// );
/// ```
Expand Down Expand Up @@ -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"
/// );
/// ```
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
6 changes: 3 additions & 3 deletions components/datetime/src/fieldsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "\"")]
/// );
/// ```
Expand Down Expand Up @@ -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, "\"")]
/// );
/// ```
Expand Down Expand Up @@ -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, "\"")]
/// );
/// ```
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
//! ```
Expand Down
10 changes: 5 additions & 5 deletions components/datetime/src/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/// );
/// ```
Expand Down Expand Up @@ -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"
/// );
/// ```
Expand All @@ -620,9 +620,9 @@ where
///
/// // the trait `GetField<AnyCalendarKind>`
/// // 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<FSet>,
Expand Down Expand Up @@ -666,7 +666,7 @@ impl<C: CldrCalendar, FSet: DateTimeMarkers> FixedCalendarDateTimeFormatter<C, F
/// let date = Date::try_new_iso(2024, 10, 14).unwrap();
///
/// assert_try_writeable_eq!(
/// formatter.format_converted(&date),
/// formatter.format_any_calendar(&date),
/// "12 Tishri 5785"
/// );
/// ```
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/tests/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ fn assert_fixture_element<A>(
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(),
Expand Down
12 changes: 6 additions & 6 deletions ffi/capi/src/datetime_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand All @@ -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(())
}

Expand All @@ -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(())
}

Expand All @@ -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(())
}
}
Expand Down Expand Up @@ -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(())
}

Expand All @@ -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(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions ffi/capi/src/zoned_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand All @@ -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(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion ffi/capi/tests/missing_apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tutorials/data_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tutorials/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn main() {
// For smaller codesize you can use FixedCalendarDateTimeFormatter<Gregorian> with a DateTime<Gregorian>
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);
}
Expand Down
2 changes: 1 addition & 1 deletion tutorials/intro_interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
```

Expand Down

0 comments on commit 8086453

Please sign in to comment.