Struct icu_datetime::neo::NeoDateFormatter

source ยท
pub struct NeoDateFormatter { /* private fields */ }
Expand description

NeoDateFormatter is a formatter capable of formatting dates from any calendar, selected at runtime. For the difference between this and TypedNeoDateFormatter, please read the crate root docs. ๐Ÿ“ This item has a stack size of 512 bytes on the stable toolchain at release date.

๐Ÿšง This code is experimental; it may change at any time, in breaking or non-breaking ways, including in SemVer minor releases. It can be enabled with the "experimental" Cargo feature of the icu meta-crate. Use with caution. #3347

Implementationsยง

sourceยง

impl NeoDateFormatter

source

pub fn try_new_with_length( locale: &DataLocale, length: Date, ) -> Result<Self, LoadError>

Construct a new NeoDateFormatter from compiled data.

This method will pick the calendar off of the locale; and if unspecified or unknown will fall back to the default calendar for the locale. See AnyCalendarKind for a list of supported calendars.

โœจ Enabled with the compiled_data Cargo feature.

๐Ÿ“š Help choosing a constructor

ยงExamples
use icu::calendar::{any_calendar::AnyCalendar, Date};
use icu::datetime::{neo::NeoDateFormatter, options::length};
use icu::locid::locale;
use icu_provider::any::DynamicDataProviderAnyMarkerWrap;
use std::str::FromStr;
use writeable::assert_try_writeable_eq;

let length = length::Date::Medium;
let locale = locale!("en-u-ca-gregory");

let df = NeoDateFormatter::try_new_with_length(&locale.into(), length)
    .expect("Failed to create TypedDateFormatter instance.");

let datetime =
    Date::try_new_iso_date(2020, 9, 1).expect("Failed to construct Date.");
let any_datetime = datetime.to_any();

assert_try_writeable_eq!(
    df.format(&any_datetime).expect("Calendars should match"),
    "Sep 1, 2020"
);
source

pub fn try_new_with_length_with_any_provider<P>( provider: &P, locale: &DataLocale, length: Date, ) -> Result<Self, LoadError>
where P: AnyProvider + ?Sized,

A version of Self::try_new_with_length that uses custom data provided by an AnyProvider.

๐Ÿ“š Help choosing a constructor

source

pub fn try_new_with_length_with_buffer_provider<P>( provider: &P, locale: &DataLocale, length: Date, ) -> Result<Self, LoadError>
where P: BufferProvider + ?Sized,

A version of Self::try_new_with_length that uses custom data provided by a BufferProvider.

โœจ Enabled with the serde feature.

๐Ÿ“š Help choosing a constructor

source

pub fn try_new_with_length_unstable<P>( provider: &P, locale: &DataLocale, length: Date, ) -> Result<Self, LoadError>
where P: ?Sized + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Buddhist> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Chinese> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Coptic> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Dangi> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Ethiopian> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::EthiopianAmeteAlem> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Gregorian> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Hebrew> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Indian> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::IslamicCivil> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::IslamicObservational> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::IslamicTabular> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::IslamicUmmAlQura> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Japanese> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::JapaneseExtended> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Persian> + DataProvider<<FullData as CalMarkers<YearNamesV1Marker>>::Roc> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Buddhist> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Chinese> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Coptic> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Dangi> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Ethiopian> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::EthiopianAmeteAlem> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Gregorian> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Hebrew> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Indian> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::IslamicCivil> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::IslamicObservational> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::IslamicTabular> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::IslamicUmmAlQura> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Japanese> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::JapaneseExtended> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Persian> + DataProvider<<FullData as CalMarkers<MonthNamesV1Marker>>::Roc> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Buddhist> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Chinese> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Coptic> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Dangi> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Ethiopian> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::EthiopianAmeteAlem> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Gregorian> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Hebrew> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Indian> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::IslamicCivil> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::IslamicObservational> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::IslamicTabular> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::IslamicUmmAlQura> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Japanese> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::JapaneseExtended> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Persian> + DataProvider<<FullData as CalMarkers<DatePatternV1Marker>>::Roc> + DataProvider<WeekdayNamesV1Marker> + DataProvider<ChineseCacheV1Marker> + DataProvider<DangiCacheV1Marker> + DataProvider<IslamicObservationalCacheV1Marker> + DataProvider<IslamicUmmAlQuraCacheV1Marker> + DataProvider<JapaneseErasV1Marker> + DataProvider<JapaneseExtendedErasV1Marker> + DataProvider<DecimalSymbolsV1Marker> + DataProvider<WeekDataV2Marker>,

A version of Self::try_new_with_length that uses custom data provided by a DataProvider.

๐Ÿ“š Help choosing a constructor

โš ๏ธ The bounds on provider may change over time, including in SemVer minor releases.
source

pub fn format<T>( &self, date: &T, ) -> Result<FormattedNeoDate<'_>, MismatchedCalendarError>
where T: DateInput<Calendar = AnyCalendar>,

Formats a date.

If the date is in neither ISO-8601 nor the same calendar system as the formatter, an error is returned.

For an example, see NeoDateFormatter.

Trait Implementationsยง

sourceยง

impl Debug for NeoDateFormatter

sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
sourceยง

impl<T> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

ยง

type Error = Infallible

The type returned in the event of a conversion error.
sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

ยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
sourceยง

impl<T> ErasedDestructor for T
where T: 'static,

sourceยง

impl<T> MaybeSendSync for T
where T: Send + Sync,