-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDayMaker.py
52 lines (39 loc) · 1.38 KB
/
DayMaker.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
49
50
51
52
# CSE 5914 Capstone Project
# Group: Ctrl+Alt+Defeat
# Application: DayMaker
## Function definitions
# Main function (called when "python DayMaker.py" is run)
def main():
# List where (index = hour * 4 + minute/15)
dayList = [-1] * 96
runTests(dayList)
def scheduleBounds(start, finish, dayList):
dayList[timeConvert(start)] = 'start'
dayList[timeConvert(finish)] = 'end'
# Given an index in the List, converts it to properly formatted military time
def indexConvert(i):
return str(int(i/4)) + ':' + str(i%4*15).zfill(2)
# Given properly formatted military time string, converts it to an index in the dayList
def timeConvert(time):
t = time.split(':')
return int(int(t[0])*4 + int(t[1])/15)
# Adds an event id to dayList based on time
def scheduleEvent(start, stop, id, dayList):
r = range(timeConvert(start), timeConvert(stop))
for i in r:
dayList[i] = id
# Test function
def runTests(dayList):
## TESTS ##
scheduleBounds('17:00', '2:30', dayList)
print(indexConvert(50))
print(timeConvert('12:30'))
scheduleEvent('20:00', '23:30', 1, dayList)
for x in range(len(dayList)):
if (dayList[x] != 1):
print(indexConvert(x) + ' - ' + str(dayList[x]))
else:
print(indexConvert(x) + ' - ' + 'Your Concert!')
# Calls the main function
if __name__== "__main__" :
main()