X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fdatetime.js;h=5addd255554a3fd365aaed01e0c254422a2afdcd;hb=dac395887d96e2d642b209c6db6aaacc3ffacb34;hp=00e8b4b9f4dfb7e55552ea418f6c95bf6c196d4d;hpb=5b87454c515b1fbf94e2c07ba7cb0cff21f38620;p=vchess.git diff --git a/client/src/utils/datetime.js b/client/src/utils/datetime.js index 00e8b4b9..5addd255 100644 --- a/client/src/utils/datetime.js +++ b/client/src/utils/datetime.js @@ -1,17 +1,17 @@ function zeroPad(x) { - return (x<10 ? "0" : "") + x; + return (x<10 ? "0" : "") + x; } export function getDate(d) { - return d.getFullYear() + '-' + zeroPad(d.getMonth()+1) + '-' + zeroPad(d.getDate()); + return d.getFullYear() + '-' + zeroPad(d.getMonth()+1) + '-' + zeroPad(d.getDate()); } export function getTime(d) { - return zeroPad(d.getHours()) + ":" + zeroPad(d.getMinutes()) + ":" + - zeroPad(d.getSeconds()); + return zeroPad(d.getHours()) + ":" + zeroPad(d.getMinutes()) + ":" + + zeroPad(d.getSeconds()); } function padDigits(x) @@ -33,11 +33,15 @@ export function ppt(t) let res = ""; if (days > 0) res += days + "d "; - if (days <= 3 && hours > 0) //TODO: 3 is arbitrary + if (days <= 3 && hours > 0) //NOTE: 3 is arbitrary 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 + } return res.trim(); //remove potential last space }