Struct time::format_description::well_known::iso8601::Config

source ·
pub struct Config {
    pub(crate) formatted_components: FormattedComponents,
    pub(crate) use_separators: bool,
    pub(crate) year_is_six_digits: bool,
    pub(crate) date_kind: DateKind,
    pub(crate) time_precision: TimePrecision,
    pub(crate) offset_precision: OffsetPrecision,
}
Expand description

Configuration for Iso8601.

Fields§

§formatted_components: FormattedComponents

Which components, if any, will be formatted.

§use_separators: bool

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

§year_is_six_digits: bool

Whether the year is six digits.

§date_kind: DateKind

The format used for the date.

§time_precision: TimePrecision

The precision and number of decimal digits present for the time.

§offset_precision: OffsetPrecision

The precision for the UTC offset.

Implementations§

source§

impl Config

source

pub const fn encode(&self) -> EncodedConfig

Encode the configuration, permitting it to be used as a const parameter of Iso8601.

The value returned by this method must only be used as a const parameter to Iso8601. Any other usage is unspecified behavior.

source

pub(super) const fn decode(encoded: EncodedConfig) -> Self

Decode the configuration. The configuration must have been generated from Config::encode.

source§

impl Config

source

pub const DEFAULT: Self = _

A configuration for the Iso8601 format.

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 the setter methods on this struct.

source

const PARSING: Self = _

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

source

pub const fn set_formatted_components( self, formatted_components: FormattedComponents, ) -> Self

Set whether the format the date, time, and/or UTC offset.

source

pub const fn set_use_separators(self, use_separators: bool) -> Self

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

source

pub const fn set_year_is_six_digits(self, year_is_six_digits: bool) -> Self

Set whether the year is six digits.

source

pub const fn set_date_kind(self, date_kind: DateKind) -> Self

Set the format used for the date.

source

pub const fn set_time_precision(self, time_precision: TimePrecision) -> Self

Set the precision and number of decimal digits present for the time.

source

pub const fn set_offset_precision( self, offset_precision: OffsetPrecision, ) -> Self

Set the precision for the UTC offset.

Trait Implementations§

source§

impl Debug for Config

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for 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, 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.