From 0619b252dd921d28f1d16d3c5df8b0d626e2e4a5 Mon Sep 17 00:00:00 2001 From: EmeraldMerchant <96396730+EmeraldMerchant@users.noreply.github.com> Date: Tue, 6 Sep 2022 11:28:39 +0800 Subject: + timeNumberDetailed added timeNumberDetailed (time, decimalPoint) (for some people asking for eg. Boss took 30.55s to kill. ish thing) --- utils/numberUtils.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'utils') 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 -- cgit