-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateTime.py
More file actions
94 lines (82 loc) · 1.9 KB
/
DateTime.py
File metadata and controls
94 lines (82 loc) · 1.9 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from itertools import permutations
def months(s):
month = []
test_list = perm(s)
print((test_list))
for i in test_list:
if i >= 0 and i <= 12:
month.append(i)
try:
month = max(month)
return month
except:
return 0
def days(s, months):
day = []
try:
for i in months:
s.remove(i)
test_list = perm(s)
for i in test_list:
if i >= 0 and i <= 31:
day.append(i)
day = max(day)
return day
except:
return 0
def hours(s, days):
hour = []
for i in days:
if i in s:
s.remove(i)
else:
continue
test_list = perm(s)
for i in test_list:
if i >= 0 and i <= 24:
hour.append(i)
try:
hour = max(hour)
return hour
except:
return 0
def seconds(s,hour):
second = []
for i in hour:
if i in s:
s.remove(i)
else:
continue
test_list = perm(s)
for i in test_list:
if i >= 0 and i <= 60:
second.append(i)
try:
second = max(second)
return second
except:
return 0
def perm(s):
a = list(permutations(s, 2))
data = [[str(x) for x in tup] for tup in a]
data = list(map(lambda x: ''.join(x), data))
print(data)
test_list = (list(map(int, data)))
return test_list
def main():
s = [0,0,1,2,2,2,3,5,9,9,9,9]
monthss = months(s)
a = [int(d) for d in str(monthss)]
dayss = days(s, a)
print(s)
b = [int(d) for d in str(dayss)]
hourss = hours(s, b)
c= [int(d) for d in str(dayss)]
secondss = seconds(s,c)
if (monthss==0 or dayss ==0 or hourss==0 or secondss==0):
retn=0
return retn
else:
retn = str(monthss)+'/'+str(dayss) + ' ' + str(hourss)+':'+str(secondss)
return retn
print(main())