Untitled

 avatar
unknown
python
3 years ago
535 B
4
Indexable
def reformat(self, date: str) -> str:
    ans = date.split()
    year = ans[2]
    months ={"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12"}
    month = months.get(ans[1])
    date = ""
    if len(ans[0])==4:
        date+= ans[0][:2]
    else:
        date+= "0"+ans[0][:1]
    return '{}-{}-{}'.format(year,month,date)
        
def preprocessDate(dates):
    result = []
    for date in dates:
        result.append(reformat(date))
    return result