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:
-
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. -
Delimited formats that start with a plausible 4-digit year (1900–2100): treated as Year-first.
-
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).
-
Strong ISO 8601 / timestamp markers (
Tconnector,Z, numeric offsets, or IANA timezone names) → Year-first. -
Fallback:
- With the
localefeature enabled: respects the system locale preference (Day-first in most of the world). - Without the
localefeature: Day-first (global majority).
- With the
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§
impl Copy for Order
Source§impl<'de> Deserialize<'de> for Order
impl<'de> Deserialize<'de> for Order
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Order
Source§impl Tsify for Order
impl Tsify for Order
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\";"
const SERIALIZATION_CONFIG: SerializationConfig
Source§type JsType = JsType
type JsType = JsType
#[wasm_bindgen] extern "C" { .. }.
Ts<T> is #[repr(transparent)] over this and passes it across the
ABI as a plain JS handle, which any other representation would break.