feat(audio): speak lap times as seconds and hundredths, "18 sixty-three" (1.89.2)

This commit is contained in:
larssand committed 2026-11-10 18:45:04 +01:00
1 parent 379dd52c7f
commit dd2fc6bd89
7 files changed
+37 -14

No files matched your search

+18 -2
View File
@@ -150,9 +150,25 @@ export function formatShortLapCall(ms, language = "sv") {
return minutes ? `${minutes} ${String(seconds).padStart(2, "0")} ${tenth}` : `${seconds} ${tenth}`;
}
// A lap time as the speaker says it: "17,18" (sv) / "17.18" (en), not "0:17.180", which voices
// read as "zero 17 comma 180". Hundredths, cut not rounded, as on the timing screens.
// A lap time as a speaker says it: seconds and hundredths as two numbers, "18 63" -> "18
// sixty-three" ("18 sextiotre"), not "0:18.630" or "18 point six three". Over a minute:
// "1 minut 05 32". Hundredths are cut, not rounded, as on the timing screens.
export function formatSpokenLapTime(ms, language = "sv") {
const value = Math.max(0, Math.floor(Number(ms) || 0));
if (!value) return "";
const minutes = Math.floor(value / 60000);
const seconds = Math.floor((value % 60000) / 1000);
// "00" would be read "hundred" by some voices: say "flat" / "jämnt" as on the passing call.
const cut = Math.floor((value % 1000) / 10);
const hundredths = cut ? String(cut).padStart(2, "0") : TENTHS[language === "en" ? "en" : "sv"][0];
if (!minutes) return `${seconds} ${hundredths}`;
const word = language === "en" ? (minutes === 1 ? "minute" : "minutes") : (minutes === 1 ? "minut" : "minuter");
return `${minutes} ${word} ${String(seconds).padStart(2, "0")} ${hundredths}`;
}
// A gap or other short time with a decimal mark: "0,30" (sv) / "0.30" (en), read as "zero
// point three zero" - a gap said as "0 30" would sound like a clock.
export function formatSpokenGap(ms, language = "sv") {
const value = Math.max(0, Math.floor(Number(ms) || 0));
if (!value) return "";
const minutes = Math.floor(value / 60000);