chrono::format

Enum Numeric

Source
#[non_exhaustive]
pub enum Numeric {
Show 21 variants Year, YearDiv100, YearMod100, IsoYear, IsoYearDiv100, IsoYearMod100, Month, Day, WeekFromSun, WeekFromMon, IsoWeek, NumDaysFromSun, WeekdayFromMon, Ordinal, Hour, Hour12, Minute, Second, Nanosecond, Timestamp, Internal(InternalNumeric),
}
Expand description

Numeric item types. They have associated formatting width (FW) and parsing width (PW).

The formatting width is the minimal width to be formatted. If the number is too short, and the padding is not Pad::None, then it is left-padded. If the number is too long or (in some cases) negative, it is printed as is.

The parsing width is the maximal width to be scanned. The parser only tries to consume from one to given number of digits (greedily). It also trims the preceding whitespace if any. It cannot parse the negative number, so some date and time cannot be formatted then parsed with the same formatting items.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Year

Full Gregorian year (FW=4, PW=∞). May accept years before 1 BCE or after 9999 CE, given an initial sign (+/-).

§

YearDiv100

Gregorian year divided by 100 (century number; FW=PW=2). Implies the non-negative year.

§

YearMod100

Gregorian year modulo 100 (FW=PW=2). Cannot be negative.

§

IsoYear

Year in the ISO week date (FW=4, PW=∞). May accept years before 1 BCE or after 9999 CE, given an initial sign.

§

IsoYearDiv100

Year in the ISO week date, divided by 100 (FW=PW=2). Implies the non-negative year.

§

IsoYearMod100

Year in the ISO week date, modulo 100 (FW=PW=2). Cannot be negative.

§

Month

Month (FW=PW=2).

§

Day

Day of the month (FW=PW=2).

§

WeekFromSun

Week number, where the week 1 starts at the first Sunday of January (FW=PW=2).

§

WeekFromMon

Week number, where the week 1 starts at the first Monday of January (FW=PW=2).

§

IsoWeek

Week number in the ISO week date (FW=PW=2).

§

NumDaysFromSun

Day of the week, where Sunday = 0 and Saturday = 6 (FW=PW=1).

§

WeekdayFromMon

Day of the week, where Monday = 1 and Sunday = 7 (FW=PW=1).

§

Ordinal

Day of the year (FW=PW=3).

§

Hour

Hour number in the 24-hour clocks (FW=PW=2).

§

Hour12

Hour number in the 12-hour clocks (FW=PW=2).

§

Minute

The number of minutes since the last whole hour (FW=PW=2).

§

Second

The number of seconds since the last whole minute (FW=PW=2).

§

Nanosecond

The number of nanoseconds since the last whole second (FW=PW=9). Note that this is not left-aligned; see also Fixed::Nanosecond.

§

Timestamp

The number of non-leap seconds since the midnight UTC on January 1, 1970 (FW=1, PW=∞). For formatting, it assumes UTC upon the absence of time zone offset.

§

Internal(InternalNumeric)

Internal uses only.

This item exists so that one can add additional internal-only formatting without breaking major compatibility (as enum variants cannot be selectively private).

Trait Implementations§

Source§

impl Clone for Numeric

Source§

fn clone(&self) -> Numeric

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Numeric

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Hash for Numeric

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Numeric

Source§

fn eq(&self, other: &Numeric) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Numeric

Source§

impl StructuralPartialEq for Numeric

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 1 byte

Size for each variant:

  • Year: 0 bytes
  • YearDiv100: 0 bytes
  • YearMod100: 0 bytes
  • IsoYear: 0 bytes
  • IsoYearDiv100: 0 bytes
  • IsoYearMod100: 0 bytes
  • Month: 0 bytes
  • Day: 0 bytes
  • WeekFromSun: 0 bytes
  • WeekFromMon: 0 bytes
  • IsoWeek: 0 bytes
  • NumDaysFromSun: 0 bytes
  • WeekdayFromMon: 0 bytes
  • Ordinal: 0 bytes
  • Hour: 0 bytes
  • Hour12: 0 bytes
  • Minute: 0 bytes
  • Second: 0 bytes
  • Nanosecond: 0 bytes
  • Timestamp: 0 bytes
  • Internal: 0 bytes (uninhabited)