MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseVttTimestamp

Function parseVttTimestamp

packages/cli/src/whisper/normalize.ts:265–277  ·  view source on GitHub ↗

Parse VTT timestamp: 00:01:23.456 or 01:23.456 → seconds

(ts: string)

Source from the content-addressed store, hash-verified

263
264/** Parse VTT timestamp: 00:01:23.456 or 01:23.456 → seconds */
265function parseVttTimestamp(ts: string): number {
266 const parts = ts.split(":");
267 if (parts.length === 3) return parseSrtTimestamp(ts);
268 // MM:SS.mmm
269 if (parts.length === 2) {
270 const [min, secMs] = parts;
271 const [sec, ms] = (secMs ?? "0.0").split(".");
272 return (
273 parseInt(min!, 10) * 60 + parseInt(sec!, 10) + parseInt((ms ?? "0").padEnd(3, "0"), 10) / 1000
274 );
275 }
276 return 0;
277}
278
279/** Format SRT timestamp: seconds → 00:01:23,456 */
280function formatSrtTimestamp(seconds: number): string {

Callers 1

parseVttFunction · 0.85

Calls 1

parseSrtTimestampFunction · 0.85

Tested by

no test coverage detected