Struct time::format_description::well_known::iso8601::Iso8601

source ·
pub struct Iso8601<const CONFIG: EncodedConfig = { Config::DEFAULT.encode() }>;
Expand description

The format described in ISO 8601.

This implementation is of ISO 8601-1:2019. It may not be compatible with other versions.

The const parameter CONFIG must be a value that was returned by Config::encode. Passing any other value is unspecified behavior.

Example: 1997-11-21T09:55:06.000000000-06:00

§Examples

assert_eq!(
    datetime!(1997-11-12 9:55:06 -6:00).format(&Iso8601::DEFAULT)?,
    "1997-11-12T09:55:06.000000000-06:00"
);
Run

Implementations§

source§

impl<const CONFIG: EncodedConfig> Iso8601<CONFIG>

source

const CONFIG: Config = _

The user-provided configuration for the ISO 8601 format.

source

pub(crate) const FORMAT_DATE: bool = _

Whether the date should be formatted.

source

pub(crate) const FORMAT_TIME: bool = _

Whether the time should be formatted.

source

pub(crate) const FORMAT_OFFSET: bool = _

Whether the UTC offset should be formatted.

source

pub(crate) const YEAR_IS_SIX_DIGITS: bool = _

Whether the year is six digits.

source

pub(crate) const USE_SEPARATORS: bool = _

Whether the format contains separators (such as - or :).

source

pub(crate) const DATE_KIND: DateKind = _

Which format to use for the date.

source

pub(crate) const TIME_PRECISION: TimePrecision = _

The precision and number of decimal digits to use for the time.

source

pub(crate) const OFFSET_PRECISION: OffsetPrecision = _

The precision for the UTC offset.

source§

impl Iso8601<DEFAULT>

source

pub const DEFAULT: Self = Self

An Iso8601 with the default configuration.

The following is the default behavior:

  • The configuration can be used for both formatting and parsing.
  • The date, time, and UTC offset are all formatted.
  • Separators (such as - and :) are included.
  • The year contains four digits, such that the year must be between 0 and 9999.
  • The date uses the calendar format.
  • The time has precision to the second and nine decimal digits.
  • The UTC offset has precision to the minute.

If you need different behavior, use another associated constant. For full customization, use Config::DEFAULT and Config’s methods to create a custom configuration.

source§

impl Iso8601<PARSING>

source

pub const PARSING: Self = Self

An Iso8601 that can only be used for parsing. Using this to format a value is unspecified behavior.

source§

impl Iso8601<DATE>

source

pub const DATE: Self = Self

An Iso8601 that handles only the date, but is otherwise the same as Config::DEFAULT.

source§

impl Iso8601<TIME>

source

pub const TIME: Self = Self

An Iso8601 that handles only the time, but is otherwise the same as Config::DEFAULT.

source§

impl Iso8601<OFFSET>

source

pub const OFFSET: Self = Self

An Iso8601 that handles only the UTC offset, but is otherwise the same as Config::DEFAULT.

source§

impl Iso8601<DATE_TIME>

source

pub const DATE_TIME: Self = Self

An Iso8601 that handles the date and time, but is otherwise the same as Config::DEFAULT.

source§

impl Iso8601<DATE_TIME_OFFSET>

source

pub const DATE_TIME_OFFSET: Self = Self

An Iso8601 that handles the date, time, and UTC offset. This is the same as Config::DEFAULT.

source§

impl Iso8601<TIME_OFFSET>

source

pub const TIME_OFFSET: Self = Self

An Iso8601 that handles the time and UTC offset, but is otherwise the same as Config::DEFAULT.

source§

impl<const CONFIG: EncodedConfig> Iso8601<CONFIG>

source

pub(crate) fn parse_date<'a>( parsed: &'a mut Parsed, extended_kind: &'a mut ExtendedKind, ) -> impl FnMut(&[u8]) -> Result<&[u8], Parse> + 'a

Parse a date in the basic or extended format. Reduced precision is permitted.

source

pub(crate) fn parse_time<'a>( parsed: &'a mut Parsed, extended_kind: &'a mut ExtendedKind, date_is_present: bool, ) -> impl FnMut(&[u8]) -> Result<&[u8], Parse> + 'a

Parse a time in the basic or extended format. Reduced precision is permitted.

source

pub(crate) fn parse_offset<'a>( parsed: &'a mut Parsed, extended_kind: &'a mut ExtendedKind, ) -> impl FnMut(&[u8]) -> Result<&[u8], Parse> + 'a

Parse a UTC offset in the basic or extended format. Reduced precision is supported.

Trait Implementations§

source§

impl<const CONFIG: EncodedConfig> Clone for Iso8601<CONFIG>

source§

fn clone(&self) -> Iso8601<CONFIG>

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<const CONFIG: EncodedConfig> Debug for Iso8601<CONFIG>

source§

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

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

impl<const CONFIG: EncodedConfig> PartialEq for Iso8601<CONFIG>

source§

fn eq(&self, other: &Iso8601<CONFIG>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const CONFIG: EncodedConfig> Sealed for Iso8601<CONFIG>

source§

fn parse_into<'a>( &self, input: &'a [u8], parsed: &mut Parsed, ) -> Result<&'a [u8], Parse>

Parse the item into the provided Parsed struct. Read more
source§

fn parse(&self, input: &[u8]) -> Result<Parsed, Parse>

Parse the item into a new Parsed struct. Read more
source§

fn parse_date(&self, input: &[u8]) -> Result<Date, Parse>

Parse a Date from the format description.
source§

fn parse_time(&self, input: &[u8]) -> Result<Time, Parse>

Parse a Time from the format description.
source§

fn parse_offset(&self, input: &[u8]) -> Result<UtcOffset, Parse>

Parse a UtcOffset from the format description.
source§

fn parse_primitive_date_time( &self, input: &[u8], ) -> Result<PrimitiveDateTime, Parse>

Parse a PrimitiveDateTime from the format description.
source§

fn parse_offset_date_time(&self, input: &[u8]) -> Result<OffsetDateTime, Parse>

Parse a OffsetDateTime from the format description.
source§

impl<const CONFIG: EncodedConfig> Sealed for Iso8601<CONFIG>

source§

fn format_into( &self, output: &mut impl Write, date: Option<Date>, time: Option<Time>, offset: Option<UtcOffset>, ) -> Result<usize, Format>

Format the item into the provided output, returning the number of bytes written.
source§

fn format( &self, date: Option<Date>, time: Option<Time>, offset: Option<UtcOffset>, ) -> Result<String, Format>

Format the item directly to a String.
source§

impl<const CONFIG: EncodedConfig> Copy for Iso8601<CONFIG>

source§

impl<const CONFIG: EncodedConfig> Eq for Iso8601<CONFIG>

source§

impl<const CONFIG: EncodedConfig> Formattable for Iso8601<CONFIG>

source§

impl<const CONFIG: EncodedConfig> Parsable for Iso8601<CONFIG>

source§

impl<const CONFIG: EncodedConfig> StructuralPartialEq for Iso8601<CONFIG>

Auto Trait Implementations§

§

impl<const CONFIG: u128> Freeze for Iso8601<CONFIG>

§

impl<const CONFIG: u128> RefUnwindSafe for Iso8601<CONFIG>

§

impl<const CONFIG: u128> Send for Iso8601<CONFIG>

§

impl<const CONFIG: u128> Sync for Iso8601<CONFIG>

§

impl<const CONFIG: u128> Unpin for Iso8601<CONFIG>

§

impl<const CONFIG: u128> UnwindSafe for Iso8601<CONFIG>

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

§

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

§

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

§

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.