Skip to main content

DateFormat

Enum DateFormat 

Source
pub enum DateFormat {
    Ymd {
        sep: char,
    },
    Mdy {
        sep: char,
        year_len: usize,
    },
    Dmy {
        sep: char,
        year_len: usize,
    },
    DMmmY {
        sep: char,
        year_len: usize,
        month_case: StringCase,
        month_full: bool,
    },
    MmmDY {
        sep: char,
        year_len: usize,
        month_case: StringCase,
        month_full: bool,
    },
    YMmmD {
        sep: char,
        year_len: usize,
        month_case: StringCase,
        month_full: bool,
    },
    Md {
        sep: char,
    },
    My {
        sep: char,
        year_len: usize,
    },
    DMmm {
        sep: char,
        month_case: StringCase,
        month_full: bool,
    },
    MmmD {
        sep: char,
        month_case: StringCase,
        month_full: bool,
    },
    MmmY {
        sep: char,
        year_len: usize,
        month_case: StringCase,
        month_full: bool,
    },
    YMmm {
        sep: char,
        year_len: usize,
        month_case: StringCase,
        month_full: bool,
    },
}
Expand description

The notation a date was written in: field order, separator, year width and month-name spelling.

This is detection output, not the storage form. A cell stores an Excel serial plus the format code this lowers to (CellStyle::num_format), which is why a DateFormat can express a little more than survives a save – month-name casing has no format-code equivalent, and zero-padding of a numeric month or day is not recorded at all, so 06/22/2026 and 6/22/2026 are the same variant and both render unpadded.

The two-part variants fill in the missing field: a month/day pair takes parse_date’s default year, a month/year pair takes day 1.

Variants§

§

Ymd

Year-month-day, all numeric: 2026-06-22.

Fields

§sep: char

Character separating the fields, - or /.

§

Mdy

Month-day-year, all numeric: 06/22/2026, 6/22/26.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§

Dmy

Day-month-year, all numeric: 22-06-2026.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§

DMmmY

Day, month name, year: 22-Jun-2026, 22-June-26.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

§

MmmDY

Month name, day, year: Jun-22-2026, June-22-26.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

§

YMmmD

Year, month name, day: 2026-Jun-22.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

§

Md

Numeric month and day, year assumed: 6/22.

Fields

§sep: char

Character separating the fields, - or /.

§

My

Numeric month and year, day assumed to be the 1st: 6/2026.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§

DMmm

Day then month name, year assumed: 22-Jun.

Fields

§sep: char

Character separating the fields, - or /.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

§

MmmD

Month name then day, year assumed: Jun-22.

Fields

§sep: char

Character separating the fields, - or /.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

§

MmmY

Month name then year, day assumed to be the 1st: Jun-2026.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

§

YMmm

Year then month name, day assumed to be the 1st: 2026-Jun.

Fields

§sep: char

Character separating the fields, - or /.

§year_len: usize

Digits the year was written with: 2 or 4.

§month_case: StringCase

Casing the month name was typed in.

§month_full: bool

true for a full name (June), false for an abbreviation (Jun).

Implementations§

Source§

impl DateFormat

Source

pub fn to_format_code(&self) -> String

Lowers to an Excel number-format code (m/d/yy, d-mmm-yyyy, …).

This is the interchange form: it is what gets written to the worksheet as a numFmt and what render_date_code consumes. Month-name casing has no representation in a format code, so it rides alongside as DateFormat::month_case.

Source

pub fn month_case(&self) -> StringCase

The casing the month name was typed in, for the formats that have one.

Trait Implementations§

Source§

impl Clone for DateFormat

Source§

fn clone(&self) -> DateFormat

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 DateFormat

Source§

impl Debug for DateFormat

Source§

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

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

impl<'de> Deserialize<'de> for DateFormat

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for DateFormat

Source§

impl PartialEq for DateFormat

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for DateFormat

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DateFormat

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V