Skip to content

Commit

Permalink
ensure 1902-01 doesn't parse to date
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfig committed Nov 1, 2024
1 parent ccca1fa commit d9dc4ec
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions quadratic-core/src/date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub fn parse_date(value: &str) -> Option<NaiveDate> {
"%d.%m.%Y",
"%Y %m %d",
"%m %d %Y",
"%d %m %Y",
"%d %m %G",
"%Y %b %d",
"%b %d %Y",
"%d %b %Y",
Expand Down Expand Up @@ -319,8 +319,7 @@ mod tests {
#[test]
#[parallel]
fn test_parse_date() {
let date = "12/23/2024".to_string();
let parsed_date = parse_date(&date).unwrap();
let parsed_date = parse_date("12/23/2024").unwrap();
assert_eq!(parsed_date, NaiveDate::from_ymd_opt(2024, 12, 23).unwrap());
assert_eq!(
parse_date("12/23/2024"),
Expand Down Expand Up @@ -414,4 +413,11 @@ mod tests {
let formatted_date = date_to_date_string(date.unwrap(), Some(format.to_string()));
assert_eq!(formatted_date, "2024 December 23 Monday".to_string());
}

#[test]
#[parallel]
fn test_parse_date_time() {
assert_eq!(parse_date("1893-01"), None);
assert_eq!(parse_date("1902-01"), None);
}
}

0 comments on commit d9dc4ec

Please sign in to comment.