better hr_time
This commit is contained in:
1 parent
7e6660002b
commit
c12a30328c
1 file changed
+10
-3
+10
-3
@@ -31,15 +31,22 @@ def hr_bytes(nbytes):
|
|||||||
|
|
||||||
def hr_time(seconds):
|
def hr_time(seconds):
|
||||||
s = ''
|
s = ''
|
||||||
|
if seconds >= 86400:
|
||||||
|
d = seconds // 86400
|
||||||
|
seconds -= d * 86400
|
||||||
|
s += f'{int(d)}d'
|
||||||
if seconds >= 3600:
|
if seconds >= 3600:
|
||||||
h = seconds // 3600
|
h = seconds // 3600
|
||||||
seconds -= h * 3600
|
seconds -= h * 3600
|
||||||
s += f'{int(h)}h'
|
s += f'{int(h)}h'
|
||||||
if seconds >= 60 or len(s) > 0:
|
if seconds >= 60:
|
||||||
m = seconds // 60
|
m = seconds // 60
|
||||||
seconds -= m * 60
|
seconds -= m * 60
|
||||||
s += f'{int(m)}m'
|
if 'd' not in s:
|
||||||
return f'{s}{int(seconds)}s'
|
s += f'{int(m)}m'
|
||||||
|
if 'h' not in s and 'd' not in s:
|
||||||
|
s += f'{int(seconds)}s'
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
class Log:
|
class Log:
|
||||||
|
|||||||
Reference in new issue
Block a user