chrono icon indicating copy to clipboard operation
chrono copied to clipboard

NaiveDate::parse_from_str with format "%d/%m/%Y" doesn't work

Open makorne opened this issue 4 years ago • 1 comments

assert!(NaiveDate::parse_from_str("2015/9/31", "%Y/%m/%d").is_err());
  
assert!(NaiveDate::parse_from_str("10/10/2021", "%d/%m/%Y").is_err());

thread 'main' panicked at 'assertion failed: NaiveDate::parse_from_str("10/10/2021", "%d/%m/%Y").is_err()',

makorne avatar Nov 13 '21 03:11 makorne

That is_err at the end means that the assertion will fail if the function was successful. The first statement was unsuccessful, probably because September only has 30 days. The second was successful.

The corollary to is_err would be is_ok, which is probably what you wanted

botahamec avatar Jun 12 '22 21:06 botahamec

I believe this issue can be closed, there is nothing to do here.

pitdicker avatar Jun 06 '23 18:06 pitdicker