feat: media & music file name

This commit is contained in:
2026-06-07 21:53:01 +03:30
parent 2be0f3e2b8
commit 944d3bc00a
3 changed files with 24 additions and 4 deletions
+10
View File
@@ -19,6 +19,16 @@ export function formatDuration(seconds?: number | null): string {
return toFa(`${m}:${String(s).padStart(2, "0")}`);
}
// Derive a clean title from an uploaded file name: drop the extension and turn
// underscores/dashes into spaces (e.g. "morning_calm-01.mp3" -> "morning calm 01").
export function fileNameToTitle(name: string): string {
return name
.replace(/\.[^./\\]+$/, "")
.replace(/[_-]+/g, " ")
.replace(/\s+/g, " ")
.trim();
}
// Minutes -> Persian label. Media and music store `duration` in minutes.
export function formatMinutes(minutes?: number | null): string {
if (minutes === null || minutes === undefined) return "—";