mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 05:01:14 -07:00
Round human duration to nearest significant base
This commit is contained in:
parent
3bb53f480e
commit
921a3a0af9
2 changed files with 4 additions and 2 deletions
|
@ -360,7 +360,8 @@ function humanDuration(ms, sig='dhm', units='ms', return_seconds=300000) {
|
|||
sig = 'dhms'
|
||||
}
|
||||
|
||||
ms = ms * factors[units];
|
||||
r = factors[sig.slice(-1)];
|
||||
ms = Math.round(ms * factors[units] / r) * r;
|
||||
|
||||
h = ms % factors['d'];
|
||||
d = Math.trunc(ms / factors['d']);
|
||||
|
|
|
@ -272,7 +272,8 @@ def human_duration(ms, sig='dhm', units='ms', return_seconds=300000):
|
|||
if return_seconds and ms < return_seconds:
|
||||
sig = 'dhms'
|
||||
|
||||
ms = ms * factors[units]
|
||||
r = factors[sig[-1]]
|
||||
ms = round(ms * factors[units] / r) * r
|
||||
|
||||
d, h = divmod(ms, factors['d'])
|
||||
h, m = divmod(h, factors['h'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue