'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)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source