Round human duration to nearest significant base

This commit is contained in:
JonnyWong16 2024-09-22 18:03:28 -07:00
parent 3bb53f480e
commit 921a3a0af9
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 4 additions and 2 deletions

View file

@ -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']);