From: Benjamin Auder Date: Tue, 3 Mar 2020 23:26:43 +0000 (+0100) Subject: Slightly better time display X-Git-Url: https://git.auder.net/img/app_dev.php/assets/parser.js?a=commitdiff_plain;h=1fba88756105dc90d240a8e5e416a59d78975f4c;p=vchess.git Slightly better time display --- 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 }