-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1507-Reformat-Date.py
More file actions
57 lines (55 loc) · 1.41 KB
/
1507-Reformat-Date.py
File metadata and controls
57 lines (55 loc) · 1.41 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
56
57
class Solution:
def reformatDate(self, date: str) -> str:
Day = {
"1st" : "01",
"2nd" : "02",
"3rd" : "03",
"4th" : "04",
"5th" : "05",
"6th" : "06",
"7th" : "07",
"8th" : "08",
"9th" : "09",
"10th" : "10",
"11th" : "11",
"12th" : "12",
"13th" : "13",
"14th" : "14",
"15th" : "15",
"16th" : "16",
"17th" : "17",
"18th" : "18",
"19th" : "19",
"20th" : "20",
"21st" : "21",
"22nd" : "22",
"23rd" : "23",
"24th" : "24",
"25th" : "25",
"26th" : "26",
"27th" : "27",
"28th" : "28",
"29th" : "29",
"30th" : "30",
"31st" : "31"
}
Month = {
"Jan": "01",
"Feb": "02",
"Mar": "03",
"Apr": "04",
"May": "05",
"Jun": "06",
"Jul": "07",
"Aug": "08",
"Sep": "09",
"Oct": "10",
"Nov": "11",
"Dec": "12"
}
Date = date.split(" ")
if Date[1] in Month:
Date[1] = Month[Date[1]]
if Date[0] in Day:
Date[0] = Day[Date[0]]
return "-".join(Date[::-1])