diff --git a/apps/pace/app.ts b/apps/pace/app.ts index a03941524..97b5b8cbe 100644 --- a/apps/pace/app.ts +++ b/apps/pace/app.ts @@ -82,8 +82,7 @@ const draw = () => { pace = "No GPS"; } - const tm = time_utils.decodeTime(exs.state.duration); - layout["time"]!.label = tm.d ? time_utils.formatDuration(tm) : time_utils.formatTime(tm); // formatTime throws if tm.d > 0 + layout["time"]!.label = formatDuration(exs.state.duration); layout["pace"]!.label = pace; layout.render(); @@ -91,6 +90,15 @@ const draw = () => { layout.forgetLazyState(), lastUnlazy = now; }; +const pad2 = (n: number) => `0${n}`.substr(-2); + +const formatDuration = (ms: number) => { + const tm = time_utils.decodeTime(ms); + if(tm.h) + return `${tm.h}:${pad2(tm.m)}:${pad2(tm.s)}`; + return `${pad2(tm.m)}:${pad2(tm.s)}`; +}; + const drawSplits = () => { g.clearRect(Bangle.appRect);