mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-14 21:45:29 +01:00
16 lines
423 B
TypeScript
16 lines
423 B
TypeScript
|
export const prettyTime = (seconds: number): string => {
|
||
|
const nSeconds = seconds % 60;
|
||
|
const nMinutes = Math.floor(seconds / 60);
|
||
|
const nHours = Math.floor(nMinutes / 60);
|
||
|
|
||
|
let res = '';
|
||
|
|
||
|
if (nHours !== 0) {
|
||
|
res += `${Math.round(nHours).toString().padStart(2, '0')}:`;
|
||
|
}
|
||
|
|
||
|
res += `${Math.round(nMinutes).toString().padStart(2, '0')}:${Math.round(nSeconds).toString().padStart(2, '0')}`;
|
||
|
|
||
|
return res;
|
||
|
};
|