1

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

Fontanka16
  • 1,161
  • 1
  • 9
  • 37
  • 1
    You mean `dateutil.parser.parse`. Indeed, even [1A2B](https://stackoverflow.com/a/75072208/357313) is a valid date, but it gives a warning. :-/ – Michel de Ruiter Jan 11 '23 at 11:17

0 Answers0