this repo has no description
1export default function formatDuration(time) {
2 if (!time) return;
3 let hours = Math.floor(time / 3600);
4 let minutes = Math.floor((time % 3600) / 60);
5 let seconds = Math.round(time % 60);
6
7 if (hours === 0) {
8 return `${minutes}:${seconds.toString().padStart(2, '0')}`;
9 } else {
10 return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds
11 .toString()
12 .padStart(2, '0')}`;
13 }
14}