feat: minute adn logo
This commit is contained in:
+12
-1
@@ -10,10 +10,21 @@ export function toFa(value: string | number | null | undefined): string {
|
||||
return String(value).replace(/\d/g, (d) => FA_DIGITS[Number(d)]);
|
||||
}
|
||||
|
||||
// Seconds -> "م:ث" style label (e.g. 90 -> ۱:۳۰).
|
||||
// Seconds -> "م:ث" style label (e.g. 90 -> ۱:۳۰). Used by the timer presets,
|
||||
// whose backend field is `duration_seconds`.
|
||||
export function formatDuration(seconds?: number | null): string {
|
||||
if (!seconds && seconds !== 0) return "—";
|
||||
const m = Math.floor(seconds / 60);
|
||||
const s = Math.floor(seconds % 60);
|
||||
return toFa(`${m}:${String(s).padStart(2, "0")}`);
|
||||
}
|
||||
|
||||
// Minutes -> Persian label. Media and music store `duration` in minutes.
|
||||
export function formatMinutes(minutes?: number | null): string {
|
||||
if (minutes === null || minutes === undefined) return "—";
|
||||
const m = Math.floor(minutes);
|
||||
if (m < 60) return toFa(`${m} دقیقه`);
|
||||
const h = Math.floor(m / 60);
|
||||
const rem = m % 60;
|
||||
return rem ? toFa(`${h} ساعت و ${rem} دقیقه`) : toFa(`${h} ساعت`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user