test file #3
49
updated_dat_num.py
Normal file
49
updated_dat_num.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
input_val = [[12, 15], [38, 42], [45.50, 47.75]]
|
||||
|
||||
# output - Monday 12:00-15:00, Tuesday 14:00-18:00, Tuesday 21:30-23:45
|
||||
2 2
|
||||
|
||||
3 3
|
||||
output = ''
|
||||
4 4
|
||||
|
||||
5 5
|
||||
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
|
||||
6 6
|
||||
|
||||
7 7
|
||||
temp_opt = []
|
||||
8 8
|
||||
def convert_float(obj):
|
||||
9 9
|
||||
if isinstance(obj, float):
|
||||
10 10
|
||||
flot = str(obj).split('.')
|
||||
11 11
|
||||
return str(int(flot[0])%24)+':'+str(60*int(flot[1])/100)
|
||||
12 12
|
||||
else:
|
||||
13 13
|
||||
return str(obj%24)+':00'
|
||||
14 14
|
||||
|
||||
15 15
|
||||
|
||||
16 16
|
||||
for objs in input_val:
|
||||
17 17
|
||||
if isinstance(objs[0], float) and isinstance(objs[1], float):
|
||||
18 18
|
||||
# import pdb;pdb.set_trace()
|
||||
19 19
|
||||
# flot = str(obj).split('.')
|
||||
20 20
|
||||
# opt.append(str(int(flot[0])%24)+':'+str(60*int(flot[1])/100))
|
||||
21 21
|
||||
temp_opt = '{}-{}'.format(convert_float(objs[0]),convert_float(objs[1]))
|
||||
22 22
|
||||
# print(convert_float(objs[0]),convert_float(objs[1]))
|
||||
23 23
|
||||
elif isinstance(objs[0], int) or isinstance(objs[1], float):
|
||||
24 24
|
||||
temp_opt = '{}-{}'.format(convert_float(objs[0]),convert_float(objs[1]))
|
||||
25 25
|
||||
# print(convert_float(objs[0]),convert_float(objs[1]))
|
||||
26 26
|
||||
elif isinstance(objs[0], float) or isinstance(objs[1], int):
|
||||
27 27
|
||||
temp_opt = '{}-{}'.format(convert_float(objs[0]),convert_float(objs[1]))
|
||||
28 28
|
||||
# print(convert_float(objs[0]),convert_float(objs[1]))
|
||||
29 29
|
||||
else:
|
||||
30 30
|
||||
temp_opt = '{}-{}'.format(convert_float(objs[0]),convert_float(objs[1]))
|
||||
31 31
|
||||
# print(convert_float(objs[0]),convert_float(objs[1]))
|
||||
32 32
|
||||
print(temp_opt)
|
||||
33 33
|
||||
|
||||
34 34
|
||||
|
||||
35 35
|
||||
|
||||
36 36
|
||||
# opt = []
|
||||
37 37
|
||||
# for obj in objs:
|
||||
38 38
|
||||
# day_obj = 0
|
||||
39 39
|
||||
# if isinstance(obj, float):
|
||||
40 40
|
||||
# flot = str(obj).split('.')
|
||||
41 41
|
||||
# # import pdb;pdb.set_trace()
|
||||
42 42
|
||||
# opt.append(str(int(flot[0])%24)+':'+str(60*int(flot[1])/100))
|
||||
43 43
|
||||
# else:
|
||||
44 44
|
||||
# opt.append(str(obj%24)+':00')
|
||||
45 45
|
||||
# day_obj = obj%24/24.0
|
||||
46 46
|
||||
# day_obj = days[int(objs[0]/24)] if isinstance(objs[0], float) else days[int(objs[0]/24)]
|
||||
47 47
|
||||
# # print(day_obj)
|
||||
48 48
|
||||
# print '-'.join(opt)
|
Reference in New Issue
Block a user
1