I want to parse dates like these into a datetime object:
The following will work for the first d
For anyone who, like me, just want something that "works" without an additional module, this is a quick and dirty solution.
string_list = ["th", "rd", "nd", "st"]
time = None
for str in string_list:
if (time is not None):
break
try:
match_string = '%B %d' + str +', %Y'
time = datetime.strptime("December 12th, 2008", match_string)
except Exception:
pass