pub struct ParseCfg {
pub parse: Option<Vec<String>>,
pub mode: Mode,
pub order: Order,
pub lang: Lang,
pub to_lower: bool,
pub relative: bool,
pub ref_time: Option<Dt>,
}Expand description
Configuration options for
Dt::from_str_parse.
Controls language, ambiguous date order, numeric parsing mode,
explicit strptime formats, relative-date support, and reference time.
These settings will not persist between parse calls and have to be used as an arg every time you want them.
Fields§
§parse: Option<Vec<String>>Explicit list of formats to try in the exact order given.
If this is provided and the vec is non-empty and the mode is Explicit
then only these formats are tried and mode and order are ignored.
If the mode is not Explicit then after trying the formats in parse the
rest of the parser will continue as normal, using mode and order.
Example:
parse: ["%Y-%m-%d", "%d/%m/%Y", "%m/%d/%Y", "%d.%m.%Y"]mode: ModeControls which preset format sets are used (astronomy/scientific formats, legacy business rules, etc.).
order: OrderControls ambiguous numeric dates.
lang: LangSets language to use for a particular parse call.
to_lower: boolWhether to lowercase the input:
ONLY set to false if the &str is already lowercase.
relative: boolWhether to parse relative dates as well as normal dates.
ref_time: Option<Dt>Reference (“current”) time used for relative expressions:
- “tomorrow”, “next Friday”, “in 3 days”, “next week”
- If
Some, thisDtis used as “now” (overrides everything). - If
None+stdfeature enabled: automatically uses real system time. - If
None+ nostd: parsing relative dates will fail with a clear error.