games_app/backend/src/utils/reportDateFormat.ts
2026-06-29 15:01:23 +02:00

14 lines
466 B
TypeScript

/** Human-readable date/time for admin report exports. */
export function formatReportDate(value: string | Date | null | undefined): string {
if (value == null || value === '') return '';
const d = value instanceof Date ? value : new Date(String(value));
if (Number.isNaN(d.getTime())) return String(value);
return d.toLocaleString('fr-FR', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
}