الملفات
back_end_oudelaa/oudelaa_dashboard/lib/format.ts
boutmoun123 637782aed6
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
Harden media health checks and duration extraction
2026-05-31 18:53:07 +03:00

33 أسطر
804 B
TypeScript

export function formatDateTime(value?: string | null) {
if (!value) return "-";
try {
return new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "short",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
hour12: true,
}).format(new Date(value));
} catch {
return value;
}
}
export function formatCurrency(value?: number | null, currency = "SAR") {
if (typeof value !== "number") return "-";
try {
return new Intl.NumberFormat("en-US", {
style: "currency",
currency,
maximumFractionDigits: 0,
}).format(value);
} catch {
return `${value} ${currency}`;
}
}
export function formatCount(value?: number | null) {
return typeof value === "number" ? new Intl.NumberFormat("en-US").format(value) : "0";
}