Skip to content

Instantly share code, notes, and snippets.

@salgo
Last active December 10, 2015 00:39
Show Gist options
  • Save salgo/4352714 to your computer and use it in GitHub Desktop.
Save salgo/4352714 to your computer and use it in GitHub Desktop.
Good work Python
def parse_ordinal_date(self, datestr):
ordinals = ['th', 'rd', 'nd', 'st']
parsed_date = None
for ordinal in ordinals:
try:
parsed_date = datetime.strptime(
datestr, '%A %d' + ordinal + ' %B %Y')
break
except ValueError:
pass
return parsed_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment