X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fdatetime.js;h=c4bbea953a33c01c875dce97bfe9583e3cc7df21;hp=75e85d714baa073efc0bc347a566a918d18b5d0b;hb=1fba88756105dc90d240a8e5e416a59d78975f4c;hpb=2d70c735a328536dcc5e1ac87bec843f288a136c 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 }