From 10ac8371cf216e800db3323f94287b58f522aade Mon Sep 17 00:00:00 2001 From: ayasayadi1 Date: Mon, 29 Apr 2024 14:20:34 +0000 Subject: [PATCH] changed formatSecond to show decimals --- .../public/javascripts/countly/countly.common.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/express/public/javascripts/countly/countly.common.js b/frontend/express/public/javascripts/countly/countly.common.js index c5611b8239a..4c73e2b40ff 100644 --- a/frontend/express/public/javascripts/countly/countly.common.js +++ b/frontend/express/public/javascripts/countly/countly.common.js @@ -4526,7 +4526,7 @@ * @example trimTo = 2, "Xh Xm Xs" result will be trimmed to "Xh Xm" */ countlyCommon.formatSecond = function(second, trimTo = 5) { - var timeLeft = parseInt(second); + var timeLeft = parseFloat(second); var dict = [ {k: 'year', v: 31536000}, {k: 'day', v: 86400}, @@ -4537,7 +4537,13 @@ var result = {year: 0, day: 0, hour: 0, minute: 0, second: 0}; var resultStrings = []; for (var i = 0; i < dict.length && resultStrings.length < 3; i++) { - result[dict[i].k] = Math.floor(timeLeft / dict[i].v); + if (dict[i].k === "second") { + //round to 1 decimal + result[dict[i].k] = Math.round(timeLeft / dict[i].v * 10) / 10; + } + else { + result[dict[i].k] = Math.floor(timeLeft / dict[i].v); + } timeLeft = timeLeft % dict[i].v; if (result[dict[i].k] > 0) { if (result[dict[i].k] === 1) {