1 year ago

#331802

test-img

Fontanka16

How to make dateutil.parse() still be agnostic to format, but require day, month and year from the string?

I use dateutil.parse() to parse out datetime strings from a file. Once in a while these strings are not actual date times. All kinds of things can be there.

My trouble is that parse() gives me false positives when I do not want it to parse. For example: dateutil.parse("99") turns into a datetime with today's date and with the year 1999.

How could I make it to raise an exception if parse() is not passed a string with year, day, and month (in various formats)?

python

python-3.x

datetime

python-dateutil

0 Answers

Your Answer

Accepted video resources