From fabe04474c9a3fe579fa0e51279fe36c52c89516 Mon Sep 17 00:00:00 2001 From: rafayghafoor Date: Sat, 30 Sep 2017 08:06:40 -0400 Subject: [PATCH] Added time conversion for parental filter --- router.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/router.py b/router.py index b9c1a8e..377a914 100755 --- a/router.py +++ b/router.py @@ -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. @@ -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 @@ -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('-')