Enum icu_datetime::fields::FieldSymbol
source · pub enum FieldSymbol {
Era,
Year(Year),
Month(Month),
Week(Week),
Day(Day),
Weekday(Weekday),
DayPeriod(DayPeriod),
Hour(Hour),
Minute,
Second(Second),
TimeZone(TimeZone),
}
Expand description
A field symbol for a date formatting pattern. Field symbols are a more granular distinction
for a pattern field within the category of a field type. Examples of field types are:
Year
, Month
, Hour
. Within the Hour
field type, examples of field symbols are: Hour::H12
,
Hour::H24
. Each field symbol is represented within the date formatting pattern string
by a distinct character from the set of A..Z
and a..z
.
Variants§
Era
Era name.
Year(Year)
Year number or year name.
Month(Month)
Month number or month name.
Week(Week)
Week number or week name.
Day(Day)
Day number relative to a time period longer than a week (ex: month, year).
Weekday(Weekday)
Day number or day name relative to a week.
DayPeriod(DayPeriod)
Name of a period within a day.
Hour(Hour)
Hour number within a day, possibly with day period.
Minute
Minute number within an hour.
Second(Second)
Seconds number within a minute, including fractional seconds, or milliseconds within a day.
TimeZone(TimeZone)
Time zone as a name, a zone ID, or a ISO 8601 numerical offset.
Implementations§
source§impl FieldSymbol
impl FieldSymbol
sourcepub(crate) fn idx(&self) -> u8
pub(crate) fn idx(&self) -> u8
Symbols are necessary components of Pattern
struct which
uses efficient byte serialization and deserialization via zerovec
.
The FieldSymbol
impl provides non-public methods that can be used to efficiently
convert between u8
and the symbol variant.
The serialization model packages the variant in one byte.
-
The top four bits are used to determine the type of the field using that type’s
idx()/from_idx()
for the mapping. (Examples:Year
,Month
,Hour
) -
The bottom four bits are used to determine the symbol of the type. (Examples:
Year::Calendar
,Hour::H11
)
§Diagram
┌─┬─┬─┬─┬─┬─┬─┬─┐
├─┴─┴─┴─┼─┴─┴─┴─┤
│ Type │Symbol │
└───────┴───────┘
§Optimization
This model is optimized to package data efficiently when FieldSymbol
is used as a variant of PatternItem
. See the documentation of PatternItemULE
for details on how it is composed.
§Constraints
This model limits the available number of possible types and symbols to 16 each.
pub(crate) fn from_idx(idx: u8) -> Result<Self, SymbolError>
source§impl FieldSymbol
impl FieldSymbol
sourcefn get_canonical_order(&self) -> u8
fn get_canonical_order(&self) -> u8
Skeletons are a Vec
This ordering is taken by the order of the fields listed in the [UTS 35 Date Field Symbol Table] (https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table), and are generally ordered most significant to least significant.
Trait Implementations§
source§impl AsULE for FieldSymbol
impl AsULE for FieldSymbol
§type ULE = FieldSymbolULE
type ULE = FieldSymbolULE
Self
. Read moresource§fn to_unaligned(self) -> Self::ULE
fn to_unaligned(self) -> Self::ULE
source§fn from_unaligned(unaligned: Self::ULE) -> Self
fn from_unaligned(unaligned: Self::ULE) -> Self
source§impl Clone for FieldSymbol
impl Clone for FieldSymbol
source§fn clone(&self) -> FieldSymbol
fn clone(&self) -> FieldSymbol
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FieldSymbol
impl Debug for FieldSymbol
source§impl From<Day> for FieldSymbol
impl From<Day> for FieldSymbol
source§impl From<DayPeriod> for FieldSymbol
impl From<DayPeriod> for FieldSymbol
source§impl From<FieldSymbol> for char
impl From<FieldSymbol> for char
source§fn from(symbol: FieldSymbol) -> Self
fn from(symbol: FieldSymbol) -> Self
source§impl From<Hour> for FieldSymbol
impl From<Hour> for FieldSymbol
source§impl From<Month> for FieldSymbol
impl From<Month> for FieldSymbol
source§impl From<Second> for FieldSymbol
impl From<Second> for FieldSymbol
source§impl From<TimeZone> for FieldSymbol
impl From<TimeZone> for FieldSymbol
source§impl From<Week> for FieldSymbol
impl From<Week> for FieldSymbol
source§impl From<Weekday> for FieldSymbol
impl From<Weekday> for FieldSymbol
source§impl From<Year> for FieldSymbol
impl From<Year> for FieldSymbol
source§impl Ord for FieldSymbol
impl Ord for FieldSymbol
source§impl PartialEq for FieldSymbol
impl PartialEq for FieldSymbol
source§fn eq(&self, other: &FieldSymbol) -> bool
fn eq(&self, other: &FieldSymbol) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for FieldSymbol
impl PartialOrd for FieldSymbol
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<char> for FieldSymbol
impl TryFrom<char> for FieldSymbol
impl Copy for FieldSymbol
impl Eq for FieldSymbol
impl StructuralPartialEq for FieldSymbol
Auto Trait Implementations§
impl Freeze for FieldSymbol
impl RefUnwindSafe for FieldSymbol
impl Send for FieldSymbol
impl Sync for FieldSymbol
impl Unpin for FieldSymbol
impl UnwindSafe for FieldSymbol
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> 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