Skip to main content

Format

Enum Format 

Source
#[non_exhaustive]
pub enum Format { Rfc3339, Rfc9557, Iso8601, Rfc2822, HttpDate, DateOnly, TimeOnly, }
Expand description

A well-known datetime representation.

§Representability

DateTime::format is infallible and best effort: it can emit a non-conforming string for out-of-domain values (for example -0001 for a negative year, or +00:19:32 for a historical offset with a seconds component). Use DateTime::try_format or DateTime::format_to when the value must be strictly valid for the requested format; both reject a year outside 0000..=9999 (except for TimeOnly) and, for Rfc3339, Rfc9557, Iso8601 and Rfc2822, an offset with a seconds component. TimeOnly is always valid.

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.
§

Rfc3339

RFC 3339 / ISO 8601, for example 2006-01-02T15:04:05Z or 2006-01-02T15:04:05+07:00.

§

Rfc9557

RFC 3339 plus an RFC 9557 time zone annotation, for example 2006-01-02T15:04:05-05:00[America/New_York].

§

Iso8601

RFC 3339, except that a zero offset is written as +00:00 rather than Z.

§

Rfc2822

RFC 2822 (email) date, for example Mon, 02 Jan 2006 15:04:05 +0000.

§

HttpDate

HTTP IMF-fixdate, for example Mon, 02 Jan 2006 15:04:05 GMT.

The value is always converted to UTC.

§

DateOnly

Just the date, for example 2006-01-02.

§

TimeOnly

Just the time, for example 15:04:05 (with fractional seconds when they are non-zero).

Trait Implementations§

Source§

impl Clone for Format

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Format

Source§

impl Debug for Format

Source§

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

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

impl Eq for Format

Source§

impl Hash for Format

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 Format

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Format

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.