Skip to main content

parse_date_text

Function parse_date_text 

Source
pub fn parse_date_text(text: &str, today: Date) -> Option<Date>
Expand description

Reads one typed date for a text field beside a picker.

Accepts YYYY-MM-DD with -, / or . separators, and these case-insensitive English forms relative to today: today, tomorrow, yesterday, in N days / in N weeks, and N days ago / N weeks ago (singular units too). The library has no clock, so the application supplies today. Returns None for anything else, including impossible dates. Pass a result to DatePickerState::set_selection, which still applies the Calendar’s bounds and disabled-date predicate.