From 04080bff00e0ef7f2d93bf84ecf0ee343c21c4f1 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Fri, 12 May 2023 06:24:57 +0000 Subject: [PATCH] Change time-counter algorythm to be more accurate. I noticed the previous implementation was wrong seconds. So I changed the thing. --- UI/UI_math.py | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/UI/UI_math.py b/UI/UI_math.py index fddffc2..9ed4cdb 100644 --- a/UI/UI_math.py +++ b/UI/UI_math.py @@ -141,41 +141,23 @@ def timestring(tleft): tleftX = tleft - tleft = int(tleftX) + seconds = int(tleftX) - addend = tleftX - tleft + addend = tleftX - seconds + afterdot = str(int(addend*100)) + if len(afterdot) < 2: + afterdot = "0"+afterdot - - valt = str(tleft) + + # This part of the function was provided by byliz55 on notabug.org for + # FastLBRY GTK. But since I'm a bad programmer. I'm using it here. - if tleft > 60 : - le = tleft - tleft = int(tleft / 60) - le = le - int(tleft * 60) - - stleft = "0"*(2-len(str(tleft)))+str(tleft) - sle = "0"*(2-len(str(le)))+str(le) - - valt = stleft+":"+ sle + m, s = divmod(seconds, 60) + h, m = divmod(m, 60) + if h: + return '{:d}:{:02d}:{:02d}'.format(h, m, s)+"."+afterdot + else: + return '{:d}:{:02d}'.format(m, s)+"."+afterdot + + - if tleft > 60 : - lele = le - le = tleft - tleft = int(tleft / 60) - le = le - int(tleft * 60) - lele = (lele - le) - if lele < 0: - lele = int(lele * -1) - - stleft = "0"*(2-len(str(tleft)))+str(tleft) - sle = "0"*(2-len(str(le)))+str(le) - slele = "0"*(2-len(str(lele)))+str(lele) - - valt = stleft+":"+ sle + ":" + slele - - if tleft > 24 : - le = tleft - tleft = int(tleft / 24) - le = le - int(tleft * 24) - valt = str(tleft)+" DAYS AND "+ str(le) + " HRS" - return valt + "." + str(int(addend*100))