fix: scan laptime formatting

This commit is contained in:
Philipp Dormann 2023-04-26 22:56:38 +02:00
parent 5e82638f35
commit 01b415d4cb
Signed by: philipp
GPG Key ID: 3BB9ADD52DCA4314

View File

@ -49,21 +49,15 @@
if (laptime == 0 || laptime == null) { if (laptime == 0 || laptime == null) {
return $_("first-scan-of-the-day"); return $_("first-scan-of-the-day");
} }
if (laptime < 60) { laptime = Number(laptime);
return `${laptime}s`; const h = Math.floor(laptime / 3600);
} const m = Math.floor((laptime % 3600) / 60);
if (laptime < 3600) { const s = Math.floor((laptime % 3600) % 60);
return `${Math.floor(laptime / 60)}min ${
laptime - Math.floor(laptime / 60) * 60 const hDisplay = h > 0 ? h + (h == 1 ? "h, " : "h, ") : "";
}s`; const mDisplay = m > 0 ? m + (m == 1 ? "min, " : "min, ") : "";
} const sDisplay = s > 0 ? s + (s == 1 ? "s" : "s") : "";
return `${Math.floor(laptime / 3600)}h ${ return hDisplay + mDisplay + sDisplay;
laptime - Math.floor(laptime / 3600) * 3600
}min ${
laptime -
Math.floor(laptime / 3600) * 3600 -
Math.floor(laptime / 60) * 60
}`;
} }
const columns = [ const columns = [