17 lines
525 B
TypeScript
17 lines
525 B
TypeScript
export const FormatTime = (time: number | null) => {
|
|
if (!time) {
|
|
return null;
|
|
} else {
|
|
const hours = Math.floor(time / (1000 * 60 * 60))
|
|
.toString()
|
|
.padStart(2, '0');
|
|
const minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60))
|
|
.toString()
|
|
.padStart(2, '0');
|
|
const seconds = Math.floor((time % (1000 * 60)) / 1000)
|
|
.toString()
|
|
.padStart(2, '0');
|
|
return `${hours}:${minutes}:${seconds}`;
|
|
}
|
|
};
|