export function faDigits(value: number | string) { return String(value).replace(/\d/g, (digit) => "۰۱۲۳۴۵۶۷۸۹"[Number(digit)]); } export function formatFaDate(value?: string | null) { if (!value) return ""; try { return new Intl.DateTimeFormat("fa-IR", { year: "numeric", month: "long", day: "numeric", }).format(new Date(value)); } catch { return value; } } export function formatFaDateLong(value?: string | null) { if (!value) return ""; try { const parts = new Intl.DateTimeFormat("fa-IR", { weekday: "long", day: "numeric", month: "long", year: "numeric", }).formatToParts(new Date(value)); const get = (type: string) => parts.find((part) => part.type === type)?.value ?? ""; return [get("weekday"), get("day"), get("month"), get("year")].filter(Boolean).join(" "); } catch { return value; } }