From 6352e4288ab5489c57ead68b97e3fc1f60bc6097 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 12 Mar 2022 22:38:01 +0530 Subject: completed week overview feature --- src/Watcher/time_operations.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/Watcher/time_operations.py') diff --git a/src/Watcher/time_operations.py b/src/Watcher/time_operations.py index 4145e8d..066a15e 100755 --- a/src/Watcher/time_operations.py +++ b/src/Watcher/time_operations.py @@ -9,12 +9,17 @@ def time_difference(a,b): # b - a sec = 60 + sec if hr < 0: hr = hr + 24 - elif int(mn) < 0 and int(sec) > 0: + elif int(mn) < 0 and int(sec) >= 0: hr = hr - 1 mn = 60 + mn elif int(sec) < 0 and int(mn) > 0: sec = 60 + sec mn = mn - 1 + elif int(sec) < 0 and int(mn) == 0: + hr = hr - 1 + mn = 59 + sec = 60 + sec + #elif int(mn) < 0: hr = str(hr).zfill(2) mn = str(mn).zfill(2) @@ -45,13 +50,14 @@ def time_addition(a,b): return result -def convert_time(t): - if int(t[0:2]) == 0: - result = t[3:5] + 'm ' + t[6::] + 's' - if int(t[3:5]) == 0: - result = t[6::] + 's' - else: - result = t[0:2] + 'h ' + t[3:5] + 'm ' + t[6::] + 's' +def format_time(t): + result = t[0:2] + 'h ' + t[3:5] + 'm ' + t[6::] + 's' + #if int(t[0:2]) == 0: + # result = t[3:5] + 'm ' + t[6::] + 's' + # if int(t[3:5]) == 0: + # result = t[6::] + 's' + #else: + # result = t[0:2] + 'h ' + t[3:5] + 'm ' + t[6::] + 's' return result def convert_into_sec(t): -- cgit v1.2.3