pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
at main 25 lines 649 B view raw
1export function formatSeconds(secs: number, showHours = false): string { 2 if (Number.isNaN(secs)) { 3 if (showHours) return "0:00:00"; 4 return "0:00"; 5 } 6 7 let time = secs; 8 const seconds = Math.floor(time % 60); 9 10 time /= 60; 11 const minutes = Math.floor(time % 60); 12 13 time /= 60; 14 const hours = Math.floor(time); 15 16 const paddedSecs = seconds.toString().padStart(2, "0"); 17 const paddedMins = minutes.toString().padStart(2, "0"); 18 19 if (!showHours) return [paddedMins, paddedSecs].join(":"); 20 return [hours, paddedMins, paddedSecs].join(":"); 21} 22 23export function durationExceedsHour(secs: number): boolean { 24 return secs > 60 * 60; 25}