blob: 2afdcbfac98caf791549396279bb6521c9d061f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// SPDX-License-Identifier: MIT
// Copyright (c) Uri Shaked and contributors
function zeroPad(value: number, length: number) {
let sval = value.toString();
while (sval.length < length) {
sval = '0' + sval;
}
return sval;
}
export function formatTime(seconds: number) {
const ms = Math.floor(seconds * 1000) % 1000;
const secs = Math.floor(seconds % 60);
const mins = Math.floor(seconds / 60);
return `${zeroPad(mins, 2)}:${zeroPad(secs, 2)}.${zeroPad(ms, 3)}`;
}
|