Parse string according to the given date format (like time.strptime()). For a list of supported format codes, see the documentation: https://docs.python.org/3/library/datetime.html#format-codes
>>> import datetime as dt >>> date_string = "02/29" >>> when = dt.date.strptime(f"{date_string};1984", "%m/%d;%Y") # Avoids leap year bug. >>> when.strftime("%B %d") 'February 29'
datetime/date.strptime
date.strptime