diff options
| author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-08 16:13:36 +0800 |
|---|---|---|
| committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-08 16:13:36 +0800 |
| commit | adb4dd3c8f01c4b732cd5b85ccdcffd4b2138737 (patch) | |
| tree | ba5d09cf87ae76dbf35a94f453507594526838f0 /utils | |
| parent | 2ee951ceaa9daebfbbe673b2f96d30b3642a2d69 (diff) | |
| download | SoopyV2-adb4dd3c8f01c4b732cd5b85ccdcffd4b2138737.tar.gz SoopyV2-adb4dd3c8f01c4b732cd5b85ccdcffd4b2138737.tar.bz2 SoopyV2-adb4dd3c8f01c4b732cd5b85ccdcffd4b2138737.zip | |
fix rounding error
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/numberUtils.js | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/utils/numberUtils.js b/utils/numberUtils.js index 97693e1..327f875 100644 --- a/utils/numberUtils.js +++ b/utils/numberUtils.js @@ -84,20 +84,12 @@ let utils = { } return utils.timeNumber(time) }, - timeNumber: (time) => { + 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}s` - }, - timeNumberDetailed: (time, decimalPoint) => { - let mins = Math.floor(time / 1000 / 60) - let tenToDecimalPower = 10 ** decimalPoint - let secs = Math.floor((time / 1000) * tenToDecimalPower)/tenToDecimalPower % 60 - - if (mins === 0) return secs + "s" - return `${mins}m ${secs}s` + return `${mins}m ${secs.toFixed(secondDecimals)}s` }, timeNumber2: (time) => { let hours = Math.floor(time / 1000 / 60 / 60) |
