-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutdated.py
More file actions
55 lines (54 loc) · 1.38 KB
/
Copy pathoutdated.py
File metadata and controls
55 lines (54 loc) · 1.38 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
month = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
def main():
while True:
try:
userInput = input("Date :")
userInput = userInput.strip()
if userInput[0:1].isdigit():
m,d,y = userInput.split("/")
m = m.strip()
if len(y) == 4 and int(m) <= 12 and int(d) <= 12:
print(f"{int(y.strip())}-{int(m):02}-{int(d):02}")
break
else:
continue
else:
day = userInput[-8:-6]
year = userInput[-5:]
monthnum = find_month(userInput, month) + 1
if int(day) <= 31:
print(f"{year.strip()}-{monthnum:02}-{int(day):02}")
break
else:
continue
except (TypeError, ValueError):
pass
else:
continue
def find_month(inp, lst):
for i in month:
if inp.startswith(i):
while True:
try:
index = lst.index(i)
return int(index)
except ValueError:
pass
else:
break
else:
continue
main()