Skip to main content

Order

Enum Order 

Source
pub enum Order {
    Smart,
    Year,
    Day,
    Month,
}
Expand description

Used by ParseCfg in Dt::from_str_parse. Controls how ambiguous dates (e.g. 01/02/03) are parsed.

The default Smart variant applies a practical heuristic that prefers year-first for compact formats and uses numeric plausibility checks for other cases. The other variants force a specific ordering.

Variants§

§

Smart

Heuristic for mixed data. Uses the following rules, in this order:

  1. Pure-numeric compact formats (≥ 6 digits with no separators, e.g. 240314153045, 20240315, YYMMDDHHMMSS): treated as Year-first (%Y%m%d / %y%m%d). These are overwhelmingly used in logs, filenames, databases, APIs, configs, and JSON for sortability.

  2. Delimited formats that start with a plausible 4-digit year (1900–2100): treated as Year-first.

  3. Numeric plausibility check (strongest universal signal):

    • First number is 13–31 → Day-first (international/European style).
    • First number is 1–12 and second number is 13–31 → Month-first (US style).
  4. Strong ISO 8601 / timestamp markers (T connector, Z, numeric offsets, or IANA timezone names) → Year-first.

  5. Fallback:

    • With the locale feature enabled: respects the system locale preference (Day-first in most of the world).
    • Without the locale feature: Day-first (global majority).

The / separator is deliberately ignored in the plausibility step because it is culturally ambiguous.

Once the preferred ordering is determined, the parser tries that order first, then the other two (e.g. Day → Month → Year), before any year-first unambiguous fallback.

§

Year

Prefer Year-first (YYYY/MM/DD or YY/MM/DD), then Day, then Month.

§

Day

Prefer Day-first (DD/MM/YYYY), then Month, then Year.

§

Month

Prefer Month-first (MM/DD/YYYY), then Day, then Year.

Trait Implementations§

Source§

impl Clone for Order

Source§

fn clone(&self) -> Order

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 Order

Source§

impl Debug for Order

Source§

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

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

impl Default for Order

Source§

fn default() -> Order

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Order

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 PartialEq for Order

Source§

fn eq(&self, other: &Order) -> 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 Order

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 Order

Source§

impl Tsify for Order

Source§

const DECL: &'static str = "/**\n * Used by [`ParseCfg`] in\n * [`Dt::from_str_parse`](../struct.Dt.html#method.from_str_parse). Controls\n * how ambiguous dates (e.g. `01/02/03`) are parsed.\n *\n * The default `Smart` variant applies a practical heuristic that prefers\n * year-first for compact formats and uses numeric plausibility checks\n * for other cases. The other variants force a specific ordering.\n */\nexport type Order = \"Smart\" | \"Year\" | \"Day\" | \"Month\";"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

Source§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

Source§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Auto Trait Implementations§

§

impl Freeze for Order

§

impl RefUnwindSafe for Order

§

impl Send for Order

§

impl Sync for Order

§

impl Unpin for Order

§

impl UnsafeUnpin for Order

§

impl UnwindSafe for Order

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

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more