Struct icu::datetime::DateTimeFormatterPreferences
source · #[non_exhaustive]pub struct DateTimeFormatterPreferences {
pub locale_prefs: LocalePreferences,
pub numbering_system: Option<NumberingSystem>,
pub hour_cycle: Option<HourCycle>,
pub calendar_algorithm: Option<CalendarAlgorithm>,
}
Expand description
The user locale preferences for datetime formatting.
§Examples
Two ways to build a preferences bag with a custom hour cycle and calendar system:
use icu::datetime::DateTimeFormatterPreferences;
use icu::locale::Locale;
use icu::locale::preferences::extensions::unicode::keywords::CalendarAlgorithm;
use icu::locale::preferences::extensions::unicode::keywords::HourCycle;
use icu::locale::subtags::Language;
let prefs1: DateTimeFormatterPreferences = Locale::try_from_str("fr-u-ca-buddhist-hc-h12").unwrap().into();
let mut prefs2 = DateTimeFormatterPreferences::default();
prefs2.locale_prefs.language = Language::try_from_str("fr").unwrap();
prefs2.hour_cycle = Some(HourCycle::H12);
prefs2.calendar_algorithm = Some(CalendarAlgorithm::Buddhist);
assert_eq!(prefs1, prefs2);
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.locale_prefs: LocalePreferences
Locale Preferences for the Preferences structure.
numbering_system: Option<NumberingSystem>
The user’s preferred numbering system.
Corresponds to the -u-nu
in Unicode Locale Identifier.
To get the resolved numbering system, you can inspect the data provider.
See the icu_decimal::provider
module for an example.
hour_cycle: Option<HourCycle>
The user’s preferred hour cycle.
Corresponds to the -u-hc
in Unicode Locale Identifier.
To get the resolved hour cycle, you can inspect the formatting pattern.
See DateTimePattern
for an example.
calendar_algorithm: Option<CalendarAlgorithm>
The user’s preferred calendar system
Corresponds to the -u-ca
in Unicode Locale Identifier.
To get the resolved calendar system, use DateTimeFormatter::calendar_kind()
.
Implementations§
source§impl DateTimeFormatterPreferences
impl DateTimeFormatterPreferences
sourcepub fn extend(&mut self, other: DateTimeFormatterPreferences)
pub fn extend(&mut self, other: DateTimeFormatterPreferences)
Extends the preferences with the values from another set of preferences.
Trait Implementations§
source§impl Clone for DateTimeFormatterPreferences
impl Clone for DateTimeFormatterPreferences
source§fn clone(&self) -> DateTimeFormatterPreferences
fn clone(&self) -> DateTimeFormatterPreferences
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DateTimeFormatterPreferences
impl Debug for DateTimeFormatterPreferences
source§impl Default for DateTimeFormatterPreferences
impl Default for DateTimeFormatterPreferences
source§fn default() -> DateTimeFormatterPreferences
fn default() -> DateTimeFormatterPreferences
source§impl From<&DateTimeFormatterPreferences> for AnyCalendarPreferences
impl From<&DateTimeFormatterPreferences> for AnyCalendarPreferences
source§fn from(other: &DateTimeFormatterPreferences) -> AnyCalendarPreferences
fn from(other: &DateTimeFormatterPreferences) -> AnyCalendarPreferences
source§impl From<&DateTimeFormatterPreferences> for FixedDecimalFormatterPreferences
impl From<&DateTimeFormatterPreferences> for FixedDecimalFormatterPreferences
source§fn from(
other: &DateTimeFormatterPreferences,
) -> FixedDecimalFormatterPreferences
fn from( other: &DateTimeFormatterPreferences, ) -> FixedDecimalFormatterPreferences
source§impl From<&LanguageIdentifier> for DateTimeFormatterPreferences
impl From<&LanguageIdentifier> for DateTimeFormatterPreferences
source§fn from(lid: &LanguageIdentifier) -> DateTimeFormatterPreferences
fn from(lid: &LanguageIdentifier) -> DateTimeFormatterPreferences
source§impl From<&Locale> for DateTimeFormatterPreferences
impl From<&Locale> for DateTimeFormatterPreferences
source§fn from(loc: &Locale) -> DateTimeFormatterPreferences
fn from(loc: &Locale) -> DateTimeFormatterPreferences
source§impl From<DateTimeFormatterPreferences> for Locale
impl From<DateTimeFormatterPreferences> for Locale
source§fn from(other: DateTimeFormatterPreferences) -> Locale
fn from(other: DateTimeFormatterPreferences) -> Locale
source§impl From<LanguageIdentifier> for DateTimeFormatterPreferences
impl From<LanguageIdentifier> for DateTimeFormatterPreferences
source§fn from(lid: LanguageIdentifier) -> DateTimeFormatterPreferences
fn from(lid: LanguageIdentifier) -> DateTimeFormatterPreferences
source§impl From<Locale> for DateTimeFormatterPreferences
impl From<Locale> for DateTimeFormatterPreferences
source§fn from(loc: Locale) -> DateTimeFormatterPreferences
fn from(loc: Locale) -> DateTimeFormatterPreferences
source§impl Hash for DateTimeFormatterPreferences
impl Hash for DateTimeFormatterPreferences
source§impl PartialEq for DateTimeFormatterPreferences
impl PartialEq for DateTimeFormatterPreferences
source§fn eq(&self, other: &DateTimeFormatterPreferences) -> bool
fn eq(&self, other: &DateTimeFormatterPreferences) -> bool
self
and other
values to be equal, and is used by ==
.impl Copy for DateTimeFormatterPreferences
impl Eq for DateTimeFormatterPreferences
impl StructuralPartialEq for DateTimeFormatterPreferences
Auto Trait Implementations§
impl Freeze for DateTimeFormatterPreferences
impl RefUnwindSafe for DateTimeFormatterPreferences
impl Send for DateTimeFormatterPreferences
impl Sync for DateTimeFormatterPreferences
impl Unpin for DateTimeFormatterPreferences
impl UnwindSafe for DateTimeFormatterPreferences
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more