pub enum Order {
Smart,
Year,
Day,
Month,
}Variants§
Smart
Default & recommended — Research-backed modern heuristic that delivers the highest real-world success rate while remaining predictable.
It uses the following prioritized rules (applied in this exact 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 the corresponding ambiguous candidate formats (Year-first → Day-first → Month-first, or the reverse, depending on the detected order) and falls back gracefully.
Year
Force Year-first only (YYYY/MM/DD or YY/MM/DD)
Day
Force Day-first only (DD/MM/YYYY)
Month
Force Month-first only (MM/DD/YYYY)