fix(audio): speak lap times as seconds with hundredths, no leading zero (1.59.1)

This commit is contained in:
larssand committed 2026-11-05 07:52:04 +01:00
1 parent db6a9f19e4
commit 12572ee31c
8 files changed
+35 -9

No files matched your search

+11
View File
@@ -115,6 +115,17 @@ export function isSilencedDuringRace(eventKey, settings, session) {
return RACE_PASSING_CALLOUT_EVENTS.includes(eventKey);
}
// 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.
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 sep = language === "en" ? "." : ",";
const seconds = `${Math.floor((value % 60000) / 1000)}${sep}${String(Math.floor((value % 1000) / 10)).padStart(2, "0")}`;
if (!minutes) return seconds;
return language === "en" ? `${minutes} ${minutes === 1 ? "minute" : "minutes"} ${seconds}` : `${minutes} ${minutes === 1 ? "minut" : "minuter"} ${seconds}`;
}
const joinUrl = (baseUrl, filePath) => `${String(baseUrl || "").replace(/\/+$/, "")}/${String(filePath || "").replace(/^\/+/, "")}`;
const interpolate = (template, variables = {}) => String(template || "").replace(/\{(\w+)\}/g, (_match, key) => String(variables[key] ?? ""));
function safeEffectPath(value) {