timeformat.ts (bf6e62f27bf21a011995d7561e0093fae1a2d72e) | timeformat.ts (4060c00a75883036bbd315fb25c90065209312b3) |
---|---|
1export default function(time: number){ 2 if(time < 60) { 3 return `00:${time.toFixed(0).padStart(2, '0')}` | 1export default function (time: number) { 2 if (time < 60) { 3 return `00:${time.toFixed(0).padStart(2, '0')}`; |
4 } 5 const sec = time % 60; 6 time = Math.floor(time / 60); 7 const min = time % 60; | 4 } 5 const sec = time % 60; 6 time = Math.floor(time / 60); 7 const min = time % 60; |
8 time = Math.floor(time /60); 9 const formatted = `${min.toString().padStart(2, '0')}:${sec.toFixed(0).padStart(2, '0')}`; 10 if(time === 0) { | 8 time = Math.floor(time / 60); 9 const formatted = `${min.toString().padStart(2, '0')}:${sec 10 .toFixed(0) 11 .padStart(2, '0')}`; 12 if (time === 0) { |
11 return formatted; 12 } 13 | 13 return formatted; 14 } 15 |
14 return `${time}:${formatted}` | 16 return `${time}:${formatted}`; |
15} | 17} |