1from datetime import datetime
2
3def try_parsing_date(text):
4 for fmt in ('%Y-%m-%d', '%d.%m.%Y', '%d/%m/%Y'):
5 try:
6 return datetime.strptime(text, fmt)
7 except ValueError:
8 pass
9 raise ValueError('no valid date format found')