From 098a0ff12f4970eff17e8c841fc4ba81bf715a6e Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 19 Mar 2022 10:46:48 +0530 Subject: error fixed in time_differnece --- src/Watcher/time_operations.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Watcher/time_operations.py b/src/Watcher/time_operations.py index 066a15e..08a42ef 100755 --- a/src/Watcher/time_operations.py +++ b/src/Watcher/time_operations.py @@ -3,19 +3,22 @@ def time_difference(a,b): # b - a hr = int(b[0:2])-int(a[0:2]) mn = int(b[3:5])-int(a[3:5]) sec = int(b[6:8])-int(a[6:8]) - if int(mn) < 0 and int(sec) < 0: + if mn < 0 and sec < 0: hr = hr - 1 mn = 60 + mn - 1 sec = 60 + sec if hr < 0: hr = hr + 24 - elif int(mn) < 0 and int(sec) >= 0: + elif mn < 0 and sec >= 0: hr = hr - 1 mn = 60 + mn - elif int(sec) < 0 and int(mn) > 0: + elif sec < 0 and mn > 0: sec = 60 + sec mn = mn - 1 - elif int(sec) < 0 and int(mn) == 0: + if hr < 0: + hr = hr + 24 + + elif sec < 0 and mn == 0: hr = hr - 1 mn = 59 sec = 60 + sec -- cgit v1.2.3