-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiming.py
48 lines (30 loc) · 1.11 KB
/
timing.py
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
def daysOfWeek():
days = ['Mon','Tue','Wed','Thu','Fri']
return days
def toMin(hour):
return (int(hour[0:2])*60 + int(hour[2:4]))
def toHour(minutes):
return ('%02d%02d'%(minutes//60, minutes%60))
def makePeriods():
start = '0800'#input('Uni Start Time: ')
end = '1800'#input('Uni End Time: ')
duration = '0130'#input('Duration of a period: ')
shortBreak = '0015'#input('Enter length of short break: ')
p = ((toMin(end)+toMin(shortBreak) - toMin(start))/(toMin(duration)+toMin(shortBreak)) )
#print('p: ',p) # for debugging
import math
#print('trunc: ',math.trunc(p)) # for debugging
periods = math.trunc(p)
temp = int(toMin(start))
timeList=[]
i = 0
while (i<periods):
other = temp + int(toMin(duration))
#print(toHour(temp),toHour(other)) #for debugging purposes
timeList.append('%s-%s'%(toHour(temp),toHour(other)))
temp = other + int(toMin(shortBreak))
i += 1
f = open('timeHeader.txt','w')
f.write(str(timeList))
f.close()
return timeList