-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoutdated.py
More file actions
36 lines (35 loc) · 826 Bytes
/
outdated.py
File metadata and controls
36 lines (35 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
while True:
date = input("Date: ").strip()
try:
if date.count("/") != 0:
mm, dd, yy = date.split("/")
if int(mm) > 12 or int(dd) > 31:
continue
print(f"{int(yy)}-{int(mm):02}-{int(dd):02}")
break
elif date.count(",") != 0:
mm, dd, yy = date.split(" ")
dd = dd.strip(",")
if int(dd) > 31:
continue
mm = mm.title()
print(f"{int(yy)}-{(months.index(mm) + 1):02}-{int(dd):02}")
break
else:
continue
except (ValueError, KeyError):
continue