Change time-counter algorythm to be more accurate.
I noticed the previous implementation was wrong seconds. So I changed the thing.
This commit is contained in:
parent
03231fa571
commit
04080bff00
1 changed files with 16 additions and 34 deletions
|
@ -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)
|
||||
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
|
||||
|
||||
stleft = "0"*(2-len(str(tleft)))+str(tleft)
|
||||
sle = "0"*(2-len(str(le)))+str(le)
|
||||
|
||||
valt = stleft+":"+ sle
|
||||
|
||||
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))
|
||||
|
|
Loading…
Reference in a new issue