pace: fix duration formatting

master
Rob Pilling 2024-10-10 18:09:10 +01:00
parent 4493b343bd
commit eabb2a8828
1 changed files with 10 additions and 2 deletions

View File

@ -82,8 +82,7 @@ const draw = () => {
pace = "No GPS"; pace = "No GPS";
} }
const tm = time_utils.decodeTime(exs.state.duration); layout["time"]!.label = formatDuration(exs.state.duration);
layout["time"]!.label = tm.d ? time_utils.formatDuration(tm) : time_utils.formatTime(tm); // formatTime throws if tm.d > 0
layout["pace"]!.label = pace; layout["pace"]!.label = pace;
layout.render(); layout.render();
@ -91,6 +90,15 @@ const draw = () => {
layout.forgetLazyState(), lastUnlazy = now; 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 = () => { const drawSplits = () => {
g.clearRect(Bangle.appRect); g.clearRect(Bangle.appRect);