- Replace the Python/Docker setup with a Rust workspace and Tauri frontend - Add core crates for archive, audio, MIDI, plugin, and desktop UI layers - Refresh the app scaffolding, build config, and documentation
28 lines
997 B
TypeScript
28 lines
997 B
TypeScript
export function formatDuration(durationMs?: number | null) {
|
|
if (!durationMs) return "--:--";
|
|
const totalSeconds = Math.floor(durationMs / 1000);
|
|
const minutes = Math.floor(totalSeconds / 60);
|
|
const seconds = totalSeconds % 60;
|
|
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
}
|
|
|
|
export function formatFileSize(sizeBytes?: number | null) {
|
|
if (!sizeBytes) return "0 B";
|
|
const units = ["B", "KB", "MB", "GB"];
|
|
let size = sizeBytes;
|
|
let index = 0;
|
|
while (size >= 1024 && index < units.length - 1) {
|
|
size /= 1024;
|
|
index += 1;
|
|
}
|
|
return `${size.toFixed(index === 0 ? 0 : 1)} ${units[index]}`;
|
|
}
|
|
|
|
export function formatCountdown(durationMs: number) {
|
|
const totalSeconds = Math.max(0, Math.floor(durationMs / 1000));
|
|
const hours = Math.floor(totalSeconds / 3600);
|
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
const seconds = totalSeconds % 60;
|
|
return [hours, minutes, seconds].map((value) => value.toString().padStart(2, "0")).join(":");
|
|
}
|