Skip to main content

parse_date

Function parse_date 

Source
pub fn parse_date(date_str: &str) -> Result<NaiveDate, ParseError>
Expand description

Parse a date string in YYYY-MM-DD format

§Examples

use things3_common::parse_date;

// Valid date
let date = parse_date("2024-01-15").unwrap();
assert_eq!(date.to_string(), "2024-01-15");

// Invalid date format returns error
assert!(parse_date("01/15/2024").is_err());
assert!(parse_date("2024-13-01").is_err()); // Invalid month

§Errors

Returns chrono::ParseError if the date string is not in the expected format