From 1fba88756105dc90d240a8e5e416a59d78975f4c Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Wed, 4 Mar 2020 00:26:43 +0100 Subject: [PATCH] Slightly better time display --- client/src/utils/datetime.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/utils/datetime.js b/client/src/utils/datetime.js index 75e85d71..c4bbea95 100644 --- a/client/src/utils/datetime.js +++ b/client/src/utils/datetime.js @@ -36,15 +36,16 @@ export function ppt(t) { const minutes = Math.floor((t % hourInSeconds) / 60); const seconds = Math.floor(t % 60); let res = ""; + // NOTE: 3 days limit is rather arbitrary + if (days >= 3 && hours >= 12) days++; if (days > 0) res += days + "d "; - if (days <= 3 && hours > 0) - //NOTE: 3 is arbitrary - res += hours + "h "; + if (days < 3 && hours > 0) res += hours + "h "; if (days == 0 && minutes > 0) res += hours > 0 ? padDigits(minutes) + "m " : minutes + ":"; if (days == 0 && hours == 0) { res += padDigits(seconds); - if (minutes == 0) res += "s"; //seconds indicator, since this is the only number printed + // Seconds indicator, since this is the only number printed: + if (minutes == 0) res += "s"; } return res.trim(); //remove potential last space } -- 2.44.0