diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-26 19:56:02 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-26 19:56:02 +0800 |
commit | a0ae59e33748047377b5ae65df675759a10bff18 (patch) | |
tree | 5358991c5b7bed018a126e9a0af1a9dc55b4a0d3 /utils/numberUtils.js | |
parent | d24e54df28d92afebcd6d890e579340df84a010b (diff) | |
download | SoopyV2-a0ae59e33748047377b5ae65df675759a10bff18.tar.gz SoopyV2-a0ae59e33748047377b5ae65df675759a10bff18.tar.bz2 SoopyV2-a0ae59e33748047377b5ae65df675759a10bff18.zip |
+ fix sending boss into to wrong players sometimes
+ fix next ch event display for some people
+ change gemstone $/h to show both hours + minuites instead of just minuites / just hours
Diffstat (limited to 'utils/numberUtils.js')
-rw-r--r-- | utils/numberUtils.js | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/utils/numberUtils.js b/utils/numberUtils.js index 96a6b74..82a6805 100644 --- a/utils/numberUtils.js +++ b/utils/numberUtils.js @@ -1,11 +1,11 @@ module.exports = { - numberWithCommas: function(x){ + numberWithCommas: function (x) { if (x === undefined) { return "" } var parts = x.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); }, - addNotation: function(type, value) { + addNotation: function (type, value) { let returnVal = value; let notList = []; if (type === "shortScale") { @@ -47,14 +47,14 @@ module.exports = { return returnVal; }, - timeSince:function (date) { + timeSince: function (date) { if (typeof date !== 'object') { date = new Date(date); } - - var seconds = Math.floor((new Date()-date) / 1000); + + var seconds = Math.floor((new Date() - date) / 1000); var intervalType; - + var interval = Math.floor(seconds / 31536000); interval = Math.floor(seconds / 86400); if (interval >= 1) { @@ -73,21 +73,29 @@ module.exports = { } } } - + return interval + '' + intervalType; }, - timeNumber: function(time){ - let mins = Math.floor(time/1000/60) - let secs = Math.floor(time/1000)%60 - - if(mins === 0) return secs + "s" + timeSince2: function (date) { + let time = Date.now() - date + + if (time > 30 * 60000) { + return this.timeNumber2(time) + } + return this.timeNumber(time) + }, + timeNumber: function (time) { + 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` }, - timeNumber2: function(time){ - let hours = Math.floor(time/1000/60/60) - let mins = Math.floor(time/1000/60)%60 - - if(hours === 0) return mins + "m" + timeNumber2: function (time) { + let hours = Math.floor(time / 1000 / 60 / 60) + let mins = Math.floor(time / 1000 / 60) % 60 + + if (hours === 0) return mins + "m" return `${hours}h ${mins}m` } }
\ No newline at end of file |