I'd like to convert this list of strings of various unknown date formats to a python datetime
object. For example:
strings = ["today", "tomorrow", "next Friday", "June 4th", "04/11/2022"]
convert_to_date(strings[0])
>>> 2022-04-08
convert_to_date(strings[1])
>>> 2022-04-09
convert_to_date(strings[3])
>>> 2022-04-15
I tried several methods but found that:
dateutil.parser
only works for dates like04/11/2022
time.strptime
andarrow
both require me to specify the formatregex
would be too complicated and may not work for all scenarios
Is there any library or function that would allow me to do something like this?