diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-06 21:08:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 21:08:59 +0800 |
commit | d9b45ed46aa28c088be652ebc4573d068e8c831c (patch) | |
tree | ea0e7b30fb0418bb1b458b84ff2194d718c3b755 | |
parent | 40a85611d97278ad08f2d095657d1ac055c80b5d (diff) | |
parent | 0619b252dd921d28f1d16d3c5df8b0d626e2e4a5 (diff) | |
download | SoopyV2-d9b45ed46aa28c088be652ebc4573d068e8c831c.tar.gz SoopyV2-d9b45ed46aa28c088be652ebc4573d068e8c831c.tar.bz2 SoopyV2-d9b45ed46aa28c088be652ebc4573d068e8c831c.zip |
Merge pull request #57 from EmeraldMerchant/patch-55
+ timeNumberDetailed
-rw-r--r-- | utils/numberUtils.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/utils/numberUtils.js b/utils/numberUtils.js index 7889d74..97693e1 100644 --- a/utils/numberUtils.js +++ b/utils/numberUtils.js @@ -5,7 +5,7 @@ let utils = { parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); }, - addNotation: function (type, value, joiner="") { + addNotation: function (type, value, joiner = "") { let returnVal = value; let notList = []; if (type === "shortScale") { @@ -91,6 +91,14 @@ let utils = { 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` + }, timeNumber2: (time) => { let hours = Math.floor(time / 1000 / 60 / 60) let mins = Math.floor(time / 1000 / 60) % 60 @@ -99,4 +107,4 @@ let utils = { return `${hours}h ${mins}m` } } -module.exports = utils
\ No newline at end of file +module.exports = utils |