Parsing date/datetime

Any crate that can parse date/datetime strings that can come in various formats, such as in WHOIS record?

Something like Python's dateutil.parse parser โ€” dateutil 2.8.2 documentation function.

belt/dateparser at main ยท waltzofpearls/belt ยท GitHub looks promising.

Do you know what the possible formats are?

Unfortunately, WHOIS doesn't have a standardized format, so no way to tell. I've not yet collected enough data to know the most frequent one. Looks like each country have their favourite date format.

What you get will probably be ambiguous, then. For example, how should the code interpret 02/04/22? Is it the 2nd of april 2022 (Australian format), 4th of February 2022 (American format), or 22nd of April 2002?

That said, maybe you are looking for the chrono crate? That will let you parse dates using the familiar strftime-like format.

2 Likes

What you get will probably be ambiguous, then

Indeed. Fortunately, dateparser pulls in chrono crate. I guess can use chrono in case I can spot an ambiguous result.

Fortunately, all dates are in the past, and I am only interested in question likes "how many years old". So, I guess I can tolerate error of a few months for some records. Not an ideal situation, but I can work on "more important" bit and focus on the edge cases later.

Thanks for suggesting chrono. It seems very popular. Added to my presonal awesome crate list.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.