update: gros commit fix editor srt panel 3

This commit is contained in:
Tom Boullay
2026-05-10 00:40:26 +01:00
parent 2757b5c389
commit a800cd2bfc
+13 -5
View File
@@ -67,15 +67,19 @@ function createSrtTemplate(
}
function formatSrtTime(totalSeconds: number): string {
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = Math.floor(totalSeconds % 60);
const safeSeconds = Math.max(0, totalSeconds);
const totalMilliseconds = Math.round(safeSeconds * 1000);
const milliseconds = totalMilliseconds % 1000;
const totalWholeSeconds = Math.floor(totalMilliseconds / 1000);
const hours = Math.floor(totalWholeSeconds / 3600);
const minutes = Math.floor((totalWholeSeconds % 3600) / 60);
const seconds = totalWholeSeconds % 60;
return `${padTime(hours)}:${padTime(minutes)}:${padTime(seconds)},000`;
return `${padTime(hours)}:${padTime(minutes)}:${padTime(seconds)},${padMilliseconds(milliseconds)}`;
}
function formatPreviewTime(totalSeconds: number): string {
return `${Math.floor(totalSeconds)}.${Math.floor((totalSeconds % 1) * 10)}s`;
return `${Math.max(0, totalSeconds).toFixed(1)}s`;
}
function parseSrtTime(value: string): number | null {
@@ -97,6 +101,10 @@ function padTime(value: number): string {
return value.toString().padStart(2, "0");
}
function padMilliseconds(value: number): string {
return value.toString().padStart(3, "0");
}
function getSrtDiagnostic(
content: string,
expectedCueIndexes: number[],