diff options
author | EmeraldMerchant <96396730+EmeraldMerchant@users.noreply.github.com> | 2022-09-14 08:11:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-14 08:11:25 +0800 |
commit | bdb7e164fe3ad56f3f61b04befe999eb134456b9 (patch) | |
tree | b5ecfb2ac3ac0c61ed10196a97e5cc259e086098 | |
parent | 01d78947793e0ee6f0b0dcbd0af072a7c9be9232 (diff) | |
download | SoopyV2-bdb7e164fe3ad56f3f61b04befe999eb134456b9.tar.gz SoopyV2-bdb7e164fe3ad56f3f61b04befe999eb134456b9.tar.bz2 SoopyV2-bdb7e164fe3ad56f3f61b04befe999eb134456b9.zip |
fix rounding error
-rw-r--r-- | utils/numberUtils.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/utils/numberUtils.js b/utils/numberUtils.js index 327f875..442015d 100644 --- a/utils/numberUtils.js +++ b/utils/numberUtils.js @@ -86,10 +86,11 @@ let utils = { }, timeNumber: (time, secondDecimals = 0) => { let mins = Math.floor(time / 1000 / 60) - let secs = Math.floor(time / 1000) % 60 - - if (mins === 0) return secs + "s" - return `${mins}m ${secs.toFixed(secondDecimals)}s` + let secs = (time / 1000) % 60 + let text = "" + if (mins === 0) text = `${secs.toFixed(secondDecimals)}s` + else text = `${mins}m ${secs.toFixed(secondDecimals)}s` + return text }, timeNumber2: (time) => { let hours = Math.floor(time / 1000 / 60 / 60) |