26 lines
488 B
JavaScript
26 lines
488 B
JavaScript
/**
|
|
* Format an ISO date string for display.
|
|
*
|
|
* @param {string|null|undefined} value
|
|
* @returns {string}
|
|
*/
|
|
export function formatDate(value) {
|
|
if (!value) {
|
|
return '—';
|
|
}
|
|
|
|
const date = new Date(value);
|
|
|
|
if (Number.isNaN(date.getTime())) {
|
|
return String(value);
|
|
}
|
|
|
|
return date.toLocaleString(undefined, {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
});
|
|
}
|