| export const inr = (n: number) => | |
| new Intl.NumberFormat("en-IN", { | |
| style: "currency", | |
| currency: "INR", | |
| maximumFractionDigits: 0, | |
| }).format(n ?? 0); | |
| export const fmtDate = (iso?: string | null) => { | |
| if (!iso) return "—"; | |
| const d = new Date(iso); | |
| if (Number.isNaN(d.getTime())) return iso; | |
| return d.toLocaleDateString("en-IN", { | |
| day: "numeric", | |
| month: "short", | |
| year: "numeric", | |
| }); | |
| }; | |
| export const fmtTime = (hhmmss?: string | null) => { | |
| if (!hhmmss) return "—"; | |
| const [h, m] = hhmmss.split(":"); | |
| const d = new Date(); | |
| d.setHours(Number(h), Number(m)); | |
| return d.toLocaleTimeString("en-IN", { hour: "numeric", minute: "2-digit" }); | |
| }; | |
| export const initials = (name?: string | null) => { | |
| if (!name) return "?"; | |
| const parts = name.trim().split(/\s+/); | |
| if (parts.length === 1) return parts[0][0]?.toUpperCase() ?? "?"; | |
| return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase(); | |
| }; | |