Skip to content

Commit

Permalink
Added time conversion for parental filter
Browse files Browse the repository at this point in the history
  • Loading branch information
RafayGhafoor committed Sep 30, 2017
1 parent 503d824 commit fabe044
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions router.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def time_limit(self, username="User_1", mac="", days="", start=1, end=24):
num_lst = []

def day_to_binary(integer):
# TODO: Add check for integer parameter.
'''
Takes an integer and divides it by 2, appends to the num_lst
and returns sum of the num_lst when it reaches 1.
Expand All @@ -199,6 +200,7 @@ def day_to_binary(integer):
return day_to_binary(integer / 2)

def convert_time(start_time="1", end_time="23:59"):
# TODO : Add test that the numbers after : shouldn't exceed 60 (minutes)
'''
Converts time to minutes.
Takes time and splits it by ":", the first element before ":" is in
Expand All @@ -216,10 +218,15 @@ def convert_time(start_time="1", end_time="23:59"):
# returns (13 * 60) + 00, (18 * 60) + 08
780, 1080
'''

start_time = start.split(':')
end_time = end.split(':')

start_time = [int(i) for i in start_time.split(':')]
end_time = [int(i) for i in end_time.split(':')]
if len(start_time) == 1:
start_time.append(00)
if len(end_time) == 1:
end_time.append(00)
start_time = (start_time[0] * 60) + start_time[1]
end_time = (end_time[0] * 60) + end_time[1]
return start_time, end_time


days = days.split('-')
Expand Down

0 comments on commit fabe044

Please sign in to comment.