pub struct FixedCalendarDateTimeNames<C, FSet: DateTimeNamesMarker = CompositeDateTimeFieldSet> { /* private fields */ }
Expand description
A low-level type that formats datetime patterns with localized names. The calendar should be chosen at compile time.
๐ This item has a stack size of 328 bytes on the stable toolchain at release date.
Type parameters:
- The calendar chosen at compile time for additional type safety
- A field set containing the fields that might be formatted
By default, the field set is set to CompositeDateTimeFieldSet
,
meaning that dates and times, but not time zones, are supported. A smaller
field set results in smaller stack size.
To support all fields including time zones, use CompositeFieldSet
.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::input::Date;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::MonthNameLength;
use icu::datetime::pattern::WeekdayNameLength;
use icu::datetime::pattern::DayPeriodNameLength;
use icu::locale::locale;
use icu::datetime::input::{DateTime, Time};
use writeable::assert_try_writeable_eq;
// Create an instance that can format abbreviated month, weekday, and day period names:
let mut names: FixedCalendarDateTimeNames<Gregorian> =
FixedCalendarDateTimeNames::try_new(locale!("uk").into()).unwrap();
names
.include_month_names(MonthNameLength::Abbreviated)
.unwrap()
.include_weekday_names(WeekdayNameLength::Abbreviated)
.unwrap()
.include_day_period_names(DayPeriodNameLength::Abbreviated)
.unwrap();
// Create a pattern from a pattern string (note: K is the hour with h11 hour cycle):
let pattern_str = "E MMM d y -- K:mm a";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
// Test it:
let datetime = DateTime { date: Date::try_new_gregorian(2023, 11, 20).unwrap(), time: Time::try_new(12, 35, 3, 0).unwrap() };
assert_try_writeable_eq!(names.with_pattern_unchecked(&pattern).format(&datetime), "ะฟะฝ ะปะธัั. 20 2023 -- 0:35 ะฟะฟ");
If the correct data is not loaded, an error will occur:
use icu::calendar::Gregorian;
use icu::datetime::input::Date;
use icu::datetime::pattern::FormattedDateTimePatternError;
use icu::datetime::parts;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::{DateTimePattern, PatternLoadError};
use icu::datetime::fieldsets::enums::CompositeFieldSet;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use icu::datetime::input::{Time, TimeZoneInfo, ZonedDateTime};
use icu_provider_adapters::empty::EmptyDataProvider;
use writeable::{Part, assert_try_writeable_parts_eq};
// Unstable API used only for error construction below
use icu::datetime::provider::fields::{Field, FieldLength, FieldSymbol, Weekday};
// Create an instance that can format all fields (CompositeFieldSet):
let mut names: FixedCalendarDateTimeNames<Gregorian, CompositeFieldSet> =
FixedCalendarDateTimeNames::try_new(locale!("en").into()).unwrap();
// Create a pattern from a pattern string:
let pattern_str = "'It is:' E MMM d y G 'at' h:mm:ssSSS a zzzz";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
// The pattern string contains lots of symbols including "E", "MMM", and "a",
// but we did not load any data!
let mut dtz = ZonedDateTime::try_full_from_str("2023-11-20T11:35:03+00:00[Europe/London]", Gregorian, IanaParser::new(), VariantOffsetsCalculator::new()).unwrap();
// Missing data is filled in on a best-effort basis, and an error is signaled.
assert_try_writeable_parts_eq!(
names.with_pattern_unchecked(&pattern).format(&dtz),
"It is: mon M11 20 2023 ce at 11:35:03.000 AM +0000",
Err(FormattedDateTimePatternError::NamesNotLoaded(Field { symbol: FieldSymbol::Weekday(Weekday::Format), length: FieldLength::One }.into())),
[
(7, 10, Part::ERROR), // mon
(7, 10, parts::WEEKDAY), // mon
(11, 14, Part::ERROR), // M11
(11, 14, parts::MONTH), // M11
(15, 17, icu::decimal::parts::INTEGER), // 20
(15, 17, parts::DAY), // 20
(18, 22, icu::decimal::parts::INTEGER), // 2023
(18, 22, parts::YEAR), // 2023
(23, 25, Part::ERROR), // CE
(23, 25, parts::ERA), // CE
(29, 31, icu::decimal::parts::INTEGER), // 11
(29, 31, parts::HOUR), // 11
(32, 34, icu::decimal::parts::INTEGER), // 35
(32, 34, parts::MINUTE), // 35
(35, 41, parts::SECOND), // 03.000
(35, 37, icu::decimal::parts::INTEGER), // 03
(37, 38, icu::decimal::parts::DECIMAL), // .
(38, 41, icu::decimal::parts::FRACTION), // 000
(42, 44, Part::ERROR), // AM
(42, 44, parts::DAY_PERIOD), // AM
(45, 50, Part::ERROR), // +0000
(45, 50, parts::TIME_ZONE_NAME), // +0000
]
);
// To make the error occur sooner, one can use an EmptyDataProvider:
let empty = EmptyDataProvider::new();
assert!(matches!(
names.load_for_pattern(&empty, &pattern),
Err(PatternLoadError::Data(_, _)),
));
If the pattern contains fields inconsistent with the receiver, an error will occur:
use icu::calendar::Gregorian;
use icu::datetime::pattern::FormattedDateTimePatternError;
use icu::datetime::parts;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::unchecked::MissingInputFieldKind;
use icu::datetime::fieldsets::zone::LocalizedOffsetLong;
use icu::locale::locale;
use icu::datetime::input::{DateTime, TimeZoneInfo};
use writeable::{Part, assert_try_writeable_parts_eq};
// Create an instance that can format abbreviated month, weekday, and day period names:
let mut names: FixedCalendarDateTimeNames<Gregorian, LocalizedOffsetLong> =
FixedCalendarDateTimeNames::try_new(locale!("en").into()).unwrap();
// Create a pattern from a pattern string:
let pattern_str = "'It is:' E MMM d y G 'at' h:mm:ssSSS a zzzz";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
// The pattern string contains lots of symbols including "E", "MMM", and "a",
// but the `FixedCalendarDateTimeNames` is configured to format only time zones!
// Further, the time zone we provide doesn't contain any offset into!
// Missing data is filled in on a best-effort basis, and an error is signaled.
assert_try_writeable_parts_eq!(
names.with_pattern_unchecked(&pattern).format(&TimeZoneInfo::unknown()),
"It is: {E} {M} {d} {y} {G} at {h}:{m}:{s} {a} {z}",
Err(FormattedDateTimePatternError::MissingInputField(MissingInputFieldKind::Weekday)),
[
(7, 10, Part::ERROR), // {E}
(7, 10, parts::WEEKDAY), // {E}
(11, 14, Part::ERROR), // {M}
(11, 14, parts::MONTH), // {M}
(15, 18, Part::ERROR), // {d}
(15, 18, parts::DAY), // {d}
(19, 22, Part::ERROR), // {y}
(19, 22, parts::YEAR), // {y}
(23, 26, Part::ERROR), // {G}
(23, 26, parts::ERA), // {G}
(30, 33, Part::ERROR), // {h}
(30, 33, parts::HOUR), // {h}
(34, 37, Part::ERROR), // {m}
(34, 37, parts::MINUTE), // {m}
(38, 41, Part::ERROR), // {s}
(38, 41, parts::SECOND), // {s}
(42, 45, Part::ERROR), // {a}
(42, 45, parts::DAY_PERIOD), // {a}
(46, 49, Part::ERROR), // {z}
(46, 49, parts::TIME_ZONE_NAME), // {z}
]
);
Multiple types of time zone data can be loaded into a FixedCalendarDateTimeNames
:
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::locale::locale;
use icu::datetime::input::{DateTime, Time};
use writeable::assert_try_writeable_eq;
// Create an instance that can format abbreviated month, weekday, and day period names:
let mut names: FixedCalendarDateTimeNames<(), ZoneFieldSet> =
FixedCalendarDateTimeNames::try_new(locale!("uk").into()).unwrap();
// Load the names for generic short:
names.include_time_zone_essentials().unwrap();
names.include_time_zone_generic_short_names().unwrap();
names.include_time_zone_location_names().unwrap();
// The same functions can be called a second time (nothing will happen):
names.include_time_zone_essentials().unwrap();
names.include_time_zone_generic_short_names().unwrap();
names.include_time_zone_location_names().unwrap();
// We can load names for a different zone style:
names.include_time_zone_generic_long_names().unwrap();
However, new time zone names cannot be added into a formatter that already has them. If you need this functionality, see https://github.com/unicode-org/icu4x/issues/6063
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::fieldsets::zone;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::NoCalendarFormatter;
use icu::locale::locale;
use icu_datetime::pattern::PatternLoadError;
use icu_provider::DataError;
use icu_provider::DataErrorKind;
let prefs = locale!("uk").into();
// Create a formatter for generic long time zones:
let formatter =
NoCalendarFormatter::try_new(prefs, zone::GenericLong).unwrap();
// Convert it to a FixedCalendarDateTimeNames:
let mut names =
FixedCalendarDateTimeNames::from_formatter(prefs, formatter)
.cast_into_fset::<ZoneFieldSet>();
// Specific names cannot be added:
assert!(matches!(
names.include_time_zone_specific_long_names(),
Err(PatternLoadError::Data(
DataError {
kind: DataErrorKind::InconsistentData(_),
..
},
_
))
));
Implementationsยง
Sourceยงimpl<C, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
impl<C, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
Sourcepub fn try_new(prefs: DateTimeFormatterPreferences) -> Result<Self, DataError>
pub fn try_new(prefs: DateTimeFormatterPreferences) -> Result<Self, DataError>
Constructor that takes a selected locale and creates an empty instance.
For an example, see FixedCalendarDateTimeNames
.
โจ Enabled with the compiled_data
Cargo feature.
Sourcepub fn try_new_unstable<P>(
provider: &P,
prefs: DateTimeFormatterPreferences,
) -> Result<Self, DataError>
pub fn try_new_unstable<P>( provider: &P, prefs: DateTimeFormatterPreferences, ) -> Result<Self, DataError>
A version of Self::try_new
that uses custom data provided by a DataProvider
.
๐ Help choosing a constructor
Sourcepub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
prefs: DateTimeFormatterPreferences,
) -> Result<Self, DataError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: DateTimeFormatterPreferences, ) -> Result<Self, DataError>
A version of [Self :: try_new
] that uses custom data provided by a BufferProvider
.
โจ Enabled with the serde
feature.
Sourcepub fn new_without_number_formatting(
prefs: DateTimeFormatterPreferences,
) -> Self
pub fn new_without_number_formatting( prefs: DateTimeFormatterPreferences, ) -> Self
Creates a completely empty instance, not even with number formatting.
ยงExamples
Errors occur if a number formatter is not loaded but one is required:
use icu::calendar::Gregorian;
use icu::datetime::input::Date;
use icu::datetime::parts;
use icu::datetime::pattern::FormattedDateTimePatternError;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::fieldsets::enums::DateFieldSet;
use icu::locale::locale;
use writeable::{Part, assert_try_writeable_parts_eq};
// Create an instance that can format only date fields:
let names: FixedCalendarDateTimeNames<Gregorian, DateFieldSet> =
FixedCalendarDateTimeNames::new_without_number_formatting(locale!("en").into());
// Create a pattern from a pattern string:
let pattern_str = "'It is:' y-MM-dd";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
// The pattern string contains lots of numeric symbols,
// but we did not load any data!
let date = Date::try_new_gregorian(2024, 7, 1).unwrap();
// Missing data is filled in on a best-effort basis, and an error is signaled.
// (note that the padding is ignored in this fallback mode)
assert_try_writeable_parts_eq!(
names.with_pattern_unchecked(&pattern).format(&date),
"It is: 2024-07-01",
Err(FormattedDateTimePatternError::DecimalFormatterNotLoaded),
[
(7, 11, Part::ERROR), // 2024
(7, 11, parts::YEAR), // 2024
(12, 14, Part::ERROR), // 07
(12, 14, parts::MONTH), // 07
(15, 17, Part::ERROR), // 01
(15, 17, parts::DAY), // 01
]
);
Sourceยงimpl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
impl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
Sourcepub fn from_formatter(
prefs: DateTimeFormatterPreferences,
formatter: FixedCalendarDateTimeFormatter<C, FSet>,
) -> Self
pub fn from_formatter( prefs: DateTimeFormatterPreferences, formatter: FixedCalendarDateTimeFormatter<C, FSet>, ) -> Self
Creates an instance with the names loaded in a FixedCalendarDateTimeFormatter
.
This function requires passing in the DateTimeFormatterPreferences
because it is not
retained in the formatter. Pass the same value or else unexpected behavior may occur.
ยงExamples
use icu::datetime::input::Date;
use icu::datetime::input::{DateTime, Time};
use icu::datetime::FixedCalendarDateTimeFormatter;
use icu::datetime::fieldsets::{YMD, YMDT};
use icu::datetime::pattern::{FixedCalendarDateTimeNames, DayPeriodNameLength};
use icu::locale::locale;
use writeable::assert_writeable_eq;
let prefs = locale!("es-MX").into();
let formatter =
FixedCalendarDateTimeFormatter::try_new(
prefs,
YMD::long(),
)
.unwrap();
assert_writeable_eq!(
formatter.format(&Date::try_new_gregorian(2025, 2, 13).unwrap()),
"13 de febrero de 2025"
);
// Change the YMD formatter to a YMDT formatter, after loading day period names.
// This assumes that the locale uses Abbreviated names for the given semantic skeleton!
let mut names = FixedCalendarDateTimeNames::from_formatter(prefs, formatter).cast_into_fset::<YMDT>();
names.include_day_period_names(DayPeriodNameLength::Abbreviated).unwrap();
let formatter = names.try_into_formatter(YMD::long().with_time_hm()).unwrap();
assert_writeable_eq!(
formatter.format(&DateTime {
date: Date::try_new_gregorian(2025, 2, 13).unwrap(),
time: Time::start_of_day(),
}),
"13 de febrero de 2025, 12:00โฏa.m."
);
Sourceยงimpl<C: CldrCalendar, FSet> FixedCalendarDateTimeNames<C, FSet>where
FSet::D: TypedDateDataMarkers<C>,
FSet::T: TimeMarkers,
FSet::Z: ZoneMarkers,
FSet: GetField<CompositeFieldSet> + DateTimeMarkers,
impl<C: CldrCalendar, FSet> FixedCalendarDateTimeNames<C, FSet>where
FSet::D: TypedDateDataMarkers<C>,
FSet::T: TimeMarkers,
FSet::Z: ZoneMarkers,
FSet: GetField<CompositeFieldSet> + DateTimeMarkers,
Sourcepub fn try_into_formatter(
self,
field_set: FSet,
) -> Result<FixedCalendarDateTimeFormatter<C, FSet>, (DateTimeFormatterLoadError, Self)>where
Baked: AllFixedCalendarPatternDataMarkers<C, FSet>,
pub fn try_into_formatter(
self,
field_set: FSet,
) -> Result<FixedCalendarDateTimeFormatter<C, FSet>, (DateTimeFormatterLoadError, Self)>where
Baked: AllFixedCalendarPatternDataMarkers<C, FSet>,
Loads a pattern for the given field set with compiled data and returns a FixedCalendarDateTimeFormatter
.
The names in the current FixedCalendarDateTimeNames
must be sufficient for the field set.
If not, the input object will be returned with an error.
โจ Enabled with the compiled_data
Cargo feature.
๐ Help choosing a constructor
ยงExamples
use icu::datetime::fieldsets::T;
use icu::datetime::input::Time;
use icu::datetime::pattern::{
DayPeriodNameLength, FixedCalendarDateTimeNames,
};
use icu::locale::locale;
use writeable::assert_writeable_eq;
let names =
FixedCalendarDateTimeNames::<(), _>::new_without_number_formatting(
locale!("es-MX").into(),
);
let field_set = T::hm();
// Cannot convert yet: no names are loaded
let mut names = names.try_into_formatter(field_set).unwrap_err().1;
// Load the data we need:
names
.include_day_period_names(DayPeriodNameLength::Abbreviated)
.unwrap();
names.include_decimal_formatter().unwrap();
// Now the conversion is successful:
let formatter = names.try_into_formatter(field_set).unwrap();
assert_writeable_eq!(formatter.format(&Time::start_of_day()), "12:00โฏa.m.");
Sourcepub fn try_into_formatter_unstable<P>(
self,
provider: &P,
field_set: FSet,
) -> Result<FixedCalendarDateTimeFormatter<C, FSet>, (DateTimeFormatterLoadError, Self)>where
P: AllFixedCalendarPatternDataMarkers<C, FSet> + ?Sized,
pub fn try_into_formatter_unstable<P>(
self,
provider: &P,
field_set: FSet,
) -> Result<FixedCalendarDateTimeFormatter<C, FSet>, (DateTimeFormatterLoadError, Self)>where
P: AllFixedCalendarPatternDataMarkers<C, FSet> + ?Sized,
A version of Self::try_into_formatter
that uses custom data provided by a DataProvider
.
๐ Help choosing a constructor
Sourcepub fn try_into_formatter_with_buffer_provider<P>(
self,
provider: &P,
field_set: FSet,
) -> Result<FixedCalendarDateTimeFormatter<C, FSet>, (DateTimeFormatterLoadError, Self)>where
P: BufferProvider + ?Sized,
pub fn try_into_formatter_with_buffer_provider<P>(
self,
provider: &P,
field_set: FSet,
) -> Result<FixedCalendarDateTimeFormatter<C, FSet>, (DateTimeFormatterLoadError, Self)>where
P: BufferProvider + ?Sized,
A version of Self::try_into_formatter
that uses custom data provided by a BufferProvider
.
โจ Enabled with the serde
feature.
Sourceยงimpl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
impl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
Sourcepub fn load_year_names<P>(
&mut self,
provider: &P,
length: YearNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn load_year_names<P>( &mut self, provider: &P, length: YearNameLength, ) -> Result<&mut Self, PatternLoadError>
Loads year (era or cycle) names for the specified length.
Does not support multiple field symbols or lengths. See #4337
Sourcepub fn include_year_names(
&mut self,
length: YearNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn include_year_names( &mut self, length: YearNameLength, ) -> Result<&mut Self, PatternLoadError>
Includes year (era or cycle) names for the specified length with compiled data.
Does not support multiple field symbols or lengths. See #4337
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::PatternLoadError;
use icu::datetime::pattern::YearNameLength;
use icu::locale::locale;
let mut names =
FixedCalendarDateTimeNames::<Gregorian>::try_new(locale!("und").into())
.unwrap();
// First length is successful:
names.include_year_names(YearNameLength::Wide).unwrap();
// Attempting to load the first length a second time will succeed:
names.include_year_names(YearNameLength::Wide).unwrap();
// But loading a new length fails:
assert!(matches!(
names.include_year_names(YearNameLength::Abbreviated),
Err(PatternLoadError::ConflictingField { .. })
));
Sourcepub fn load_month_names<P>(
&mut self,
provider: &P,
length: MonthNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn load_month_names<P>( &mut self, provider: &P, length: MonthNameLength, ) -> Result<&mut Self, PatternLoadError>
Loads month names for the specified symbol and length.
Does not support multiple field symbols or lengths. See #4337
Sourcepub fn include_month_names(
&mut self,
length: MonthNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn include_month_names( &mut self, length: MonthNameLength, ) -> Result<&mut Self, PatternLoadError>
Includes month names for the specified symbol and length with compiled data.
Does not support multiple field symbols or lengths. See #4337
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::MonthNameLength;
use icu::datetime::pattern::PatternLoadError;
use icu::locale::locale;
let mut names =
FixedCalendarDateTimeNames::<Gregorian>::try_new(locale!("und").into())
.unwrap();
// First length is successful:
names.include_month_names(MonthNameLength::Wide).unwrap();
// Attempting to load the first length a second time will succeed:
names.include_month_names(MonthNameLength::Wide).unwrap();
// But loading a new symbol or length fails:
assert!(matches!(
names.include_month_names(MonthNameLength::StandaloneWide),
Err(PatternLoadError::ConflictingField { .. })
));
assert!(matches!(
names.include_month_names(MonthNameLength::Abbreviated),
Err(PatternLoadError::ConflictingField { .. })
));
Sourceยงimpl<C, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
impl<C, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
Sourcepub fn load_day_period_names<P>(
&mut self,
provider: &P,
length: DayPeriodNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn load_day_period_names<P>( &mut self, provider: &P, length: DayPeriodNameLength, ) -> Result<&mut Self, PatternLoadError>
Loads day period names for the specified length.
Does not support multiple field symbols or lengths. See #4337
Sourcepub fn include_day_period_names(
&mut self,
length: DayPeriodNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn include_day_period_names( &mut self, length: DayPeriodNameLength, ) -> Result<&mut Self, PatternLoadError>
Includes day period names for the specified length with compiled data.
Does not support multiple field symbols or lengths. See #4337
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::pattern::DayPeriodNameLength;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::PatternLoadError;
use icu::locale::locale;
let mut names =
FixedCalendarDateTimeNames::<Gregorian>::try_new(locale!("und").into())
.unwrap();
// First length is successful:
names
.include_day_period_names(DayPeriodNameLength::Wide)
.unwrap();
// Attempting to load the first length a second time will succeed:
names
.include_day_period_names(DayPeriodNameLength::Wide)
.unwrap();
// But loading a new length fails:
assert!(matches!(
names.include_day_period_names(DayPeriodNameLength::Abbreviated),
Err(PatternLoadError::ConflictingField { .. })
));
Sourcepub fn load_weekday_names<P>(
&mut self,
provider: &P,
length: WeekdayNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn load_weekday_names<P>( &mut self, provider: &P, length: WeekdayNameLength, ) -> Result<&mut Self, PatternLoadError>
Loads weekday names for the specified symbol and length.
Does not support multiple field symbols or lengths. See #4337
Sourcepub fn include_weekday_names(
&mut self,
length: WeekdayNameLength,
) -> Result<&mut Self, PatternLoadError>
pub fn include_weekday_names( &mut self, length: WeekdayNameLength, ) -> Result<&mut Self, PatternLoadError>
Includes weekday names for the specified symbol and length with compiled data.
Does not support multiple field symbols or lengths. See #4337
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::PatternLoadError;
use icu::datetime::pattern::WeekdayNameLength;
use icu::locale::locale;
let mut names =
FixedCalendarDateTimeNames::<Gregorian>::try_new(locale!("und").into())
.unwrap();
// First length is successful:
names
.include_weekday_names(WeekdayNameLength::Wide)
.unwrap();
// Attempting to load the first length a second time will succeed:
names
.include_weekday_names(WeekdayNameLength::Wide)
.unwrap();
// But loading a new symbol or length fails:
assert!(matches!(
names.include_weekday_names(WeekdayNameLength::StandaloneWide),
Err(PatternLoadError::ConflictingField { .. })
));
assert!(matches!(
names.include_weekday_names(WeekdayNameLength::Abbreviated),
Err(PatternLoadError::ConflictingField { .. })
));
Sourcepub fn load_time_zone_essentials<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>
pub fn load_time_zone_essentials<P>( &mut self, provider: &P, ) -> Result<&mut Self, PatternLoadError>
Loads shared essential patterns for time zone formatting.
Sourcepub fn include_time_zone_essentials(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_essentials( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes shared essential patterns for time zone formatting with compiled data.
This data should always be loaded when performing time zone formatting. By itself, it allows localized offset formats.
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut zone_london_summer = ZonedDateTime::try_full_from_str(
"2024-07-01T00:00:00+01:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_essentials().unwrap();
// Create a pattern with symbol `OOOO`:
let pattern_str = "'Your time zone is:' OOOO";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: GMT+00:00",
);
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_summer),
"Your time zone is: GMT+01:00",
);
// Now try `V`:
let pattern_str = "'Your time zone is:' V";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: gblon",
);
// Now try `Z`:
let pattern_str = "'Your time zone is:' Z";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: +0000",
);
// Now try `ZZZZZ`:
let pattern_str = "'Your time zone is:' ZZZZZ";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: Z",
);
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_summer),
"Your time zone is: +01:00",
);
Sourcepub fn load_time_zone_location_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>
pub fn load_time_zone_location_names<P>( &mut self, provider: &P, ) -> Result<&mut Self, PatternLoadError>
Loads location names for time zone formatting.
Sourcepub fn include_time_zone_location_names(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_location_names( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes location names for time zone formatting with compiled data.
Important: When performing manual time zone data loading, in addition to the specific time zone format data, also call either:
FixedCalendarDateTimeNames::include_time_zone_essentials
FixedCalendarDateTimeNames::load_time_zone_essentials
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_essentials().unwrap();
names.include_time_zone_location_names().unwrap();
// Try `VVVV`:
let pattern_str = "'Your time zone is:' VVVV";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: UK Time",
);
Sourcepub fn load_time_zone_exemplar_city_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<TimezoneNamesCitiesOverrideV1> + DataProvider<TimezoneNamesCitiesRootV1> + ?Sized,
pub fn load_time_zone_exemplar_city_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<TimezoneNamesCitiesOverrideV1> + DataProvider<TimezoneNamesCitiesRootV1> + ?Sized,
Loads exemplar city names for time zone formatting.
Sourcepub fn include_time_zone_exemplar_city_names(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_exemplar_city_names( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes exemplar city names for time zone formatting with compiled data.
Important: The VVV
format requires location data in addition to exemplar
city data. Also call either:
FixedCalendarDateTimeNames::include_time_zone_location_names
FixedCalendarDateTimeNames::load_time_zone_location_names
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_location_names().unwrap();
names.include_time_zone_exemplar_city_names().unwrap();
// Try `VVVV`:
let pattern_str = "'Your time zone is:' VVV";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: London",
);
Sourcepub fn load_time_zone_generic_long_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>
pub fn load_time_zone_generic_long_names<P>( &mut self, provider: &P, ) -> Result<&mut Self, PatternLoadError>
Loads generic non-location long time zone names.
Sourcepub fn include_time_zone_generic_long_names(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_generic_long_names( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes generic non-location long time zone names with compiled data.
Important: When performing manual time zone data loading, in addition to the specific time zone format data, also call either:
FixedCalendarDateTimeNames::include_time_zone_essentials
FixedCalendarDateTimeNames::load_time_zone_essentials
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut zone_london_summer = ZonedDateTime::try_full_from_str(
"2024-07-01T00:00:00+01:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_essentials().unwrap();
names.include_time_zone_generic_long_names().unwrap();
// Create a pattern with symbol `vvvv`:
let pattern_str = "'Your time zone is:' vvvv";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: Greenwich Mean Time",
);
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_summer),
// Note: The year-round generic name of this zone is Greenwich
// Mean Time, which may be confusing since the zone observes
// daylight savings time. See:
// <https://unicode-org.atlassian.net/issues/CLDR-18378>
"Your time zone is: Greenwich Mean Time",
);
Sourcepub fn load_time_zone_generic_short_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<TimezoneNamesGenericShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
pub fn load_time_zone_generic_short_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<TimezoneNamesGenericShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
Loads generic non-location short time zone names.
Sourcepub fn include_time_zone_generic_short_names(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_generic_short_names( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes generic non-location short time zone names with compiled data.
Important: When performing manual time zone data loading, in addition to the specific time zone format data, also call either:
FixedCalendarDateTimeNames::include_time_zone_essentials
FixedCalendarDateTimeNames::load_time_zone_essentials
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut zone_london_summer = ZonedDateTime::try_full_from_str(
"2024-07-01T00:00:00+01:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_essentials().unwrap();
names.include_time_zone_generic_short_names().unwrap();
// Create a pattern with symbol `v`:
let pattern_str = "'Your time zone is:' v";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: GMT",
);
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_summer),
// Note: The year-round generic name of this zone is Greenwich
// Mean Time, which may be confusing since the zone observes
// daylight savings time. See:
// <https://unicode-org.atlassian.net/issues/CLDR-18378>
"Your time zone is: GMT",
);
Sourcepub fn load_time_zone_specific_long_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>
pub fn load_time_zone_specific_long_names<P>( &mut self, provider: &P, ) -> Result<&mut Self, PatternLoadError>
Loads specific non-location long time zone names.
Sourcepub fn include_time_zone_specific_long_names(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_specific_long_names( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes specific non-location long time zone names with compiled data.
Important: When performing manual time zone data loading, in addition to the specific time zone format data, also call either:
FixedCalendarDateTimeNames::include_time_zone_essentials
FixedCalendarDateTimeNames::load_time_zone_essentials
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut zone_london_summer = ZonedDateTime::try_full_from_str(
"2024-07-01T00:00:00+01:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_essentials().unwrap();
names.include_time_zone_specific_long_names().unwrap();
// Create a pattern with symbol `zzzz`:
let pattern_str = "'Your time zone is:' zzzz";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: Greenwich Mean Time",
);
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_summer),
"Your time zone is: British Summer Time",
);
Sourcepub fn load_time_zone_specific_short_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<TimezoneNamesSpecificShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
pub fn load_time_zone_specific_short_names<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<TimezoneNamesSpecificShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
Loads specific non-location short time zone names.
Sourcepub fn include_time_zone_specific_short_names(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_specific_short_names( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes specific non-location short time zone names with compiled data.
Important: When performing manual time zone data loading, in addition to the specific time zone format data, also call either:
FixedCalendarDateTimeNames::include_time_zone_essentials
FixedCalendarDateTimeNames::load_time_zone_essentials
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::ZoneFieldSet;
use icu::datetime::input::ZonedDateTime;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use icu::time::zone::{IanaParser, VariantOffsetsCalculator};
use writeable::assert_try_writeable_eq;
let mut zone_london_winter = ZonedDateTime::try_full_from_str(
"2024-01-01T00:00:00+00:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut zone_london_summer = ZonedDateTime::try_full_from_str(
"2024-07-01T00:00:00+01:00[Europe/London]",
Gregorian,
IanaParser::new(),
VariantOffsetsCalculator::new(),
)
.unwrap()
.zone;
let mut names =
FixedCalendarDateTimeNames::<Gregorian, ZoneFieldSet>::try_new(
locale!("en-GB").into(),
)
.unwrap();
names.include_time_zone_essentials().unwrap();
names.include_time_zone_specific_short_names().unwrap();
// Create a pattern with symbol `z`:
let pattern_str = "'Your time zone is:' z";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_winter),
"Your time zone is: GMT",
);
assert_try_writeable_eq!(
names
.with_pattern_unchecked(&pattern)
.format(&zone_london_summer),
"Your time zone is: BST",
);
Sourcepub fn load_time_zone_generic_short_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesGenericShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
pub fn load_time_zone_generic_short_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesGenericShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
Loads generic non-location short time zone names and all data required for its fallback formats.
See GenericShort
Sourcepub fn include_time_zone_generic_short_names_with_fallback(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_generic_short_names_with_fallback( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes generic non-location short time zone names and all data required for its fallback formats, with compiled data.
See GenericShort
โจ Enabled with the compiled_data
Cargo feature.
Sourcepub fn load_time_zone_generic_long_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesGenericLongV1> + DataProvider<TimezoneNamesStandardLongV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
pub fn load_time_zone_generic_long_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesGenericLongV1> + DataProvider<TimezoneNamesStandardLongV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
Loads generic non-location long time zone names and all data required for its fallback formats.
See GenericLong
Sourcepub fn include_time_zone_generic_long_names_with_fallback(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_generic_long_names_with_fallback( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes generic non-location long time zone names and all data required for its fallback formats, with compiled data.
See GenericLong
โจ Enabled with the compiled_data
Cargo feature.
Sourcepub fn load_time_zone_specific_short_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesSpecificShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
pub fn load_time_zone_specific_short_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesSpecificShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
Loads specific non-location short time zone names and all data required for its fallback formats except for decimal formatting.
See SpecificShort
Sourcepub fn include_time_zone_specific_short_names_with_fallback(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_specific_short_names_with_fallback( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes specific non-location short time zone names and all data required for its fallback formats except for decimal formatting, with compiled data.
See SpecificShort
โจ Enabled with the compiled_data
Cargo feature.
Sourcepub fn load_time_zone_specific_long_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesSpecificLongV1> + DataProvider<TimezoneNamesStandardLongV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
pub fn load_time_zone_specific_long_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesSpecificLongV1> + DataProvider<TimezoneNamesStandardLongV1> + DataProvider<TimezoneMetazonePeriodsV1> + ?Sized,
Loads specific non-location long time zone names and all data required for its fallback formats except for decimal formatting.
See SpecificLong
Sourcepub fn include_time_zone_specific_long_names_with_fallback(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_specific_long_names_with_fallback( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes specific non-location long time zone names and all data required for its fallback formats except for decimal formatting, with compiled data.
See SpecificLong
โจ Enabled with the compiled_data
Cargo feature.
Sourcepub fn load_time_zone_localized_offset_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + ?Sized,
pub fn load_time_zone_localized_offset_names_with_fallback<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, PatternLoadError>where
P: DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + DataProvider<TimezoneNamesEssentialsV1> + ?Sized,
Loads all data for short and long localized offset time zone formatting except for decimal formatting.
See:
Sourcepub fn include_time_zone_localized_offset_names_with_fallback(
&mut self,
) -> Result<&mut Self, PatternLoadError>
pub fn include_time_zone_localized_offset_names_with_fallback( &mut self, ) -> Result<&mut Self, PatternLoadError>
Includes all data for short and long localized offset time zone formatting except for decimal formatting, with compiled data.
See:
โจ Enabled with the compiled_data
Cargo feature.
Sourcepub fn load_decimal_formatter<P>(
&mut self,
provider: &P,
) -> Result<&mut Self, DataError>
pub fn load_decimal_formatter<P>( &mut self, provider: &P, ) -> Result<&mut Self, DataError>
Loads a DecimalFormatter
from a data provider.
Sourcepub fn include_decimal_formatter(&mut self) -> Result<&mut Self, DataError>
pub fn include_decimal_formatter(&mut self) -> Result<&mut Self, DataError>
Loads a DecimalFormatter
with compiled data.
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::datetime::fieldsets::enums::TimeFieldSet;
use icu::datetime::input::Time;
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use writeable::assert_try_writeable_eq;
let mut names = FixedCalendarDateTimeNames::<(), TimeFieldSet>::try_new(
locale!("bn").into(),
)
.unwrap();
names.include_decimal_formatter();
// Create a pattern for the time, which is all numbers
let pattern_str = "'The current 24-hour time is:' HH:mm";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
let time = Time::try_new(6, 40, 33, 0).unwrap();
assert_try_writeable_eq!(
names.with_pattern_unchecked(&pattern).format(&time),
"The current 24-hour time is: เงฆเงฌ:เงชเงฆ",
);
Sourceยงimpl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
impl<C: CldrCalendar, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
Sourcepub fn with_pattern_unchecked<'l>(
&'l self,
pattern: &'l DateTimePattern,
) -> DateTimePatternFormatter<'l, C, FSet>
pub fn with_pattern_unchecked<'l>( &'l self, pattern: &'l DateTimePattern, ) -> DateTimePatternFormatter<'l, C, FSet>
Associates this FixedCalendarDateTimeNames
with a pattern
without checking that all necessary data is loaded.
Use this function if you know at compile time what fields your pattern contains.
Sourcepub fn load_for_pattern<'l, P>(
&'l mut self,
provider: &P,
pattern: &'l DateTimePattern,
) -> Result<DateTimePatternFormatter<'l, C, FSet>, PatternLoadError>where
P: DataProvider<C::YearNamesV1> + DataProvider<C::MonthNamesV1> + DataProvider<WeekdayNamesV1> + DataProvider<DayPeriodNamesV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesCitiesOverrideV1> + DataProvider<TimezoneNamesCitiesRootV1> + DataProvider<TimezoneNamesGenericLongV1> + DataProvider<TimezoneNamesGenericShortV1> + DataProvider<TimezoneNamesStandardLongV1> + DataProvider<TimezoneNamesSpecificLongV1> + DataProvider<TimezoneNamesSpecificShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + ?Sized,
pub fn load_for_pattern<'l, P>(
&'l mut self,
provider: &P,
pattern: &'l DateTimePattern,
) -> Result<DateTimePatternFormatter<'l, C, FSet>, PatternLoadError>where
P: DataProvider<C::YearNamesV1> + DataProvider<C::MonthNamesV1> + DataProvider<WeekdayNamesV1> + DataProvider<DayPeriodNamesV1> + DataProvider<TimezoneNamesEssentialsV1> + DataProvider<TimezoneNamesLocationsOverrideV1> + DataProvider<TimezoneNamesLocationsRootV1> + DataProvider<TimezoneNamesCitiesOverrideV1> + DataProvider<TimezoneNamesCitiesRootV1> + DataProvider<TimezoneNamesGenericLongV1> + DataProvider<TimezoneNamesGenericShortV1> + DataProvider<TimezoneNamesStandardLongV1> + DataProvider<TimezoneNamesSpecificLongV1> + DataProvider<TimezoneNamesSpecificShortV1> + DataProvider<TimezoneMetazonePeriodsV1> + DataProvider<DecimalSymbolsV1> + DataProvider<DecimalDigitsV1> + ?Sized,
Associates this FixedCalendarDateTimeNames
with a datetime pattern
and loads all data required for that pattern.
Does not duplicate textual field symbols. See #4337
Sourcepub fn include_for_pattern<'l>(
&'l mut self,
pattern: &'l DateTimePattern,
) -> Result<DateTimePatternFormatter<'l, C, FSet>, PatternLoadError>
pub fn include_for_pattern<'l>( &'l mut self, pattern: &'l DateTimePattern, ) -> Result<DateTimePatternFormatter<'l, C, FSet>, PatternLoadError>
Associates this FixedCalendarDateTimeNames
with a pattern
and includes all data required for that pattern, from compiled data.
Does not support duplicate textual field symbols. See #4337
โจ Enabled with the compiled_data
Cargo feature.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::input::Date;
use icu::datetime::input::{DateTime, Time};
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::locale::locale;
use writeable::assert_try_writeable_eq;
let mut names =
FixedCalendarDateTimeNames::<Gregorian>::try_new(locale!("en").into())
.unwrap();
// Create a pattern from a pattern string:
let pattern_str = "MMM d (EEEE) 'of year' y G 'at' h:mm a";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
// Load data for the pattern and format:
let datetime = DateTime {
date: Date::try_new_gregorian(2023, 12, 5).unwrap(),
time: Time::try_new(17, 43, 12, 0).unwrap(),
};
assert_try_writeable_eq!(
names
.include_for_pattern(&pattern)
.unwrap()
.format(&datetime),
"Dec 5 (Tuesday) of year 2023 AD at 5:43 PM"
);
Sourceยงimpl<C, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
impl<C, FSet: DateTimeNamesMarker> FixedCalendarDateTimeNames<C, FSet>
Sourcepub fn cast_into_fset<FSet2: DateTimeNamesFrom<FSet>>(
self,
) -> FixedCalendarDateTimeNames<C, FSet2>
pub fn cast_into_fset<FSet2: DateTimeNamesFrom<FSet>>( self, ) -> FixedCalendarDateTimeNames<C, FSet2>
Maps a FixedCalendarDateTimeNames
of a specific FSet
to a more general FSet
.
For example, this can transform a formatter for DateFieldSet
to one for
CompositeDateTimeFieldSet
.
ยงExamples
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::enums::{
CompositeDateTimeFieldSet, DateFieldSet,
};
use icu::datetime::input::Date;
use icu::datetime::input::{DateTime, Time};
use icu::datetime::pattern::DateTimePattern;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::pattern::MonthNameLength;
use icu::locale::locale;
use writeable::assert_try_writeable_eq;
// Create an instance that can format abbreviated month names:
let mut names: FixedCalendarDateTimeNames<Gregorian, DateFieldSet> =
FixedCalendarDateTimeNames::try_new(locale!("uk").into()).unwrap();
names
.include_month_names(MonthNameLength::Abbreviated)
.unwrap();
// Test it with a pattern:
let pattern_str = "MMM d y";
let pattern: DateTimePattern = pattern_str.parse().unwrap();
let datetime = DateTime {
date: Date::try_new_gregorian(2023, 11, 20).unwrap(),
time: Time::start_of_day(),
};
assert_try_writeable_eq!(
names.with_pattern_unchecked(&pattern).format(&datetime),
"ะปะธัั. 20 2023"
);
// Convert the field set to `CompositeDateTimeFieldSet`:
let composite_names = names.cast_into_fset::<CompositeDateTimeFieldSet>();
// It should still work:
assert_try_writeable_eq!(
composite_names
.with_pattern_unchecked(&pattern)
.format(&datetime),
"ะปะธัั. 20 2023"
);
Converting into a narrower type is not supported:
use icu::calendar::Gregorian;
use icu::datetime::pattern::FixedCalendarDateTimeNames;
use icu::datetime::fieldsets::enums::{DateFieldSet, CompositeDateTimeFieldSet};
let composite_names: FixedCalendarDateTimeNames<Gregorian, CompositeDateTimeFieldSet> = todo!();
// error[E0277]: the trait bound `(): From<DataPayloadWithVariables<DayPeriodNamesV1, FieldLength>>` is not satisfied
let narrow_names = composite_names.cast_into_fset::<DateFieldSet>();
Trait Implementationsยง
Sourceยงimpl<FSet: DateTimeNamesMarker> AsMut<FixedCalendarDateTimeNames<(), FSet>> for DateTimeNames<FSet>
impl<FSet: DateTimeNamesMarker> AsMut<FixedCalendarDateTimeNames<(), FSet>> for DateTimeNames<FSet>
Sourceยงfn as_mut(&mut self) -> &mut FixedCalendarDateTimeNames<(), FSet>
fn as_mut(&mut self) -> &mut FixedCalendarDateTimeNames<(), FSet>
Sourceยงimpl<FSet: DateTimeNamesMarker> AsRef<FixedCalendarDateTimeNames<(), FSet>> for DateTimeNames<FSet>
impl<FSet: DateTimeNamesMarker> AsRef<FixedCalendarDateTimeNames<(), FSet>> for DateTimeNames<FSet>
Sourceยงfn as_ref(&self) -> &FixedCalendarDateTimeNames<(), FSet>
fn as_ref(&self) -> &FixedCalendarDateTimeNames<(), FSet>
Sourceยงimpl<C: Clone, FSet: Clone + DateTimeNamesMarker> Clone for FixedCalendarDateTimeNames<C, FSet>
impl<C: Clone, FSet: Clone + DateTimeNamesMarker> Clone for FixedCalendarDateTimeNames<C, FSet>
Sourceยงfn clone(&self) -> FixedCalendarDateTimeNames<C, FSet>
fn clone(&self) -> FixedCalendarDateTimeNames<C, FSet>
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementationsยง
impl<C, FSet> Freeze for FixedCalendarDateTimeNames<C, FSet>where
<<FSet as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container: Freeze,
<<FSet as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezoneMetazonePeriodsV1, ()>>::Container: Freeze,
impl<C, FSet> RefUnwindSafe for FixedCalendarDateTimeNames<C, FSet>where
<<FSet as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container: RefUnwindSafe,
<<FSet as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezoneMetazonePeriodsV1, ()>>::Container: RefUnwindSafe,
C: RefUnwindSafe,
FSet: RefUnwindSafe,
impl<C, FSet = CompositeDateTimeFieldSet> !Send for FixedCalendarDateTimeNames<C, FSet>
impl<C, FSet = CompositeDateTimeFieldSet> !Sync for FixedCalendarDateTimeNames<C, FSet>
impl<C, FSet> Unpin for FixedCalendarDateTimeNames<C, FSet>where
<<FSet as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container: Unpin,
<<FSet as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezoneMetazonePeriodsV1, ()>>::Container: Unpin,
C: Unpin,
FSet: Unpin,
impl<C, FSet> UnwindSafe for FixedCalendarDateTimeNames<C, FSet>where
<<FSet as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container: UnwindSafe,
<<FSet as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezoneMetazonePeriodsV1, ()>>::Container: UnwindSafe,
C: UnwindSafe,
FSet: UnwindSafe,
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ยง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