bspeice/dtparse

Empty string return today's date

Closed this issue · 2 comments

Running

fn main() {
    println!("{:?}", dtparse::parse(""))
}

Will output

Ok((2020-06-11T00:00:00, None))

Python dateutil return an error in this case.

>>> from dateutil import parser
>>> parser.parse("")
...
dateutil.parser._parser.ParserError: String does not contain a date:

Is it possible to have the same behavior?

Definitely. Need to figure out how best to implement it, but differences between the results of dateutil and dtparse are considered a bug.

The way dateutil handles this strikes me as incredibly weird; using len() to count the number of set fields is strange. Regardless, the fix should be landing shortly, and I'll cut a new version this afternoon.