mirror of https://github.com/espruino/BangleApps
clkinfostopw: format hours/minutes/seconds
parent
ae74346bb1
commit
7aa89220be
|
@ -0,0 +1 @@
|
||||||
|
0.01: New clkinfo!
|
|
@ -13,7 +13,25 @@
|
||||||
redrawInterval = setInterval(() => this.emit('redraw'), 100);
|
redrawInterval = setInterval(() => this.emit('redraw'), 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
const duration = () => ((Date.now() - startTime) / 1000).toFixed(1);
|
const pad2 = s => ('0' + s.toFixed(0)).slice(-2);
|
||||||
|
|
||||||
|
const duration = () => {
|
||||||
|
let seconds = (Date.now() - startTime) / 1000;
|
||||||
|
|
||||||
|
if (seconds < 60)
|
||||||
|
return seconds.toFixed(1);
|
||||||
|
|
||||||
|
let mins = seconds / 60;
|
||||||
|
seconds %= 60;
|
||||||
|
|
||||||
|
if (mins < 60)
|
||||||
|
return `${pad2(mins)}m${pad2(seconds)}s`;
|
||||||
|
|
||||||
|
let hours = mins / 60;
|
||||||
|
mins %= 60;
|
||||||
|
|
||||||
|
return `${Math.round(hours)}h${pad2(mins)}m${pad2(seconds)}s`;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "timer",
|
name: "timer",
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"type": "clkinfo",
|
"type": "clkinfo",
|
||||||
"tags": "clkinfo,timer",
|
"tags": "clkinfo,timer",
|
||||||
"supports" : ["BANGLEJS2"],
|
"supports" : ["BANGLEJS2"],
|
||||||
|
"allow_emulator": true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"stopw.clkinfo.js","url":"clkinfo.js"}
|
{"name":"stopw.clkinfo.js","url":"clkinfo.js"}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue