3 return (x
<10 ? "0" : "") + x
;
6 export function getDate(d
)
8 return d
.getFullYear() + '-' + zeroPad(d
.getMonth()+1) + '-' + zeroPad(d
.getDate());
11 export function getTime(d
)
13 return zeroPad(d
.getHours()) + ":" + zeroPad(d
.getMinutes()) + ":" +
14 zeroPad(d
.getSeconds());
24 export function ppt(t
)
26 // "Pretty print" an amount of time given in seconds
27 const dayInSeconds
= 60 * 60 * 24;
28 const hourInSeconds
= 60 * 60;
29 const days
= Math
.floor(t
/ dayInSeconds
);
30 const hours
= Math
.floor(t
%dayInSeconds
/ hourInSeconds
);
31 const minutes
= Math
.floor(t
%hourInSeconds
/ 60);
32 const seconds
= Math
.floor(t
% 60);
36 if (days
<= 3 && hours
> 0) //NOTE: 3 is arbitrary
38 if (days
== 0 && minutes
> 0)
39 res
+= (hours
> 0 ? padDigits(minutes
) + "m " : minutes
+ ":");
40 if (days
== 0 && hours
== 0)
42 res
+= padDigits(seconds
);
44 res
+= "s"; //seconds indicator, since this is the only number printed
46 return res
.trim(); //remove potential last space