feat: initial
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// Tiny className combiner (avoids an extra dependency).
|
||||
export function cn(...parts: Array<string | false | null | undefined>): string {
|
||||
return parts.filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
// Convert ASCII digits to Persian digits for display.
|
||||
const FA_DIGITS = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
|
||||
export function toFa(value: string | number | null | undefined): string {
|
||||
if (value === null || value === undefined) return "";
|
||||
return String(value).replace(/\d/g, (d) => FA_DIGITS[Number(d)]);
|
||||
}
|
||||
|
||||
// Seconds -> "م:ث" style label (e.g. 90 -> ۱:۳۰).
|
||||
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")}`);
|
||||
}
|
||||
Reference in New Issue
Block a user