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.