xref: /MusicFree/src/utils/timeformat.ts (revision 7a91f04f28a4f3fa6393ee470f3a347e72fdfc41)
1bf6e62f2S猫头猫export default function (time: number) {
2bf6e62f2S猫头猫    if (time < 60) {
34060c00aS猫头猫        return `00:${time.toFixed(0).padStart(2, '0')}`;
4bf6e62f2S猫头猫    }
5*7a91f04fS猫头猫    const sec = Math.floor(time % 60);
6bf6e62f2S猫头猫    time = Math.floor(time / 60);
7bf6e62f2S猫头猫    const min = time % 60;
8bf6e62f2S猫头猫    time = Math.floor(time / 60);
94060c00aS猫头猫    const formatted = `${min.toString().padStart(2, '0')}:${sec
104060c00aS猫头猫        .toFixed(0)
114060c00aS猫头猫        .padStart(2, '0')}`;
12bf6e62f2S猫头猫    if (time === 0) {
13bf6e62f2S猫头猫        return formatted;
14bf6e62f2S猫头猫    }
15bf6e62f2S猫头猫
164060c00aS猫头猫    return `${time}:${formatted}`;
17bf6e62f2S猫头猫}
18