def convert_date(date: str) -> str:
try:
dd, mm, yyyy = date.split('/')
assert (0 < int(dd) < 32) and (0 < int(mm) < 13) and (1900 <= int(yyyy) <= 2100)
if int(mm) == 2 and int(yyyy) % 4 != 0:
raise ValueError()
return f'{yyyy}-{mm}-{dd}'
except:
return 'Error: Invalid date.'>
Created at: 2024/05/01 11:38; Updated at: 2024/05/01 18:15
The question is resolved.