28 lines
779 B
TypeScript
28 lines
779 B
TypeScript
export function formatDate(value: string | null | undefined) {
|
|
if (!value) return '-';
|
|
return new Intl.DateTimeFormat('en-IN', {
|
|
dateStyle: 'medium',
|
|
timeStyle: 'short',
|
|
}).format(new Date(value));
|
|
}
|
|
|
|
export function formatDateOnly(value: string | null | undefined) {
|
|
if (!value) return '-';
|
|
return new Intl.DateTimeFormat('en-IN', { dateStyle: 'medium' }).format(
|
|
new Date(value),
|
|
);
|
|
}
|
|
|
|
export function formatTimelineDateTime(value: string | null | undefined) {
|
|
if (!value) return { date: '-', time: '-' };
|
|
|
|
const parsed = new Date(value);
|
|
return {
|
|
date: new Intl.DateTimeFormat('en-IN', { dateStyle: 'medium' }).format(
|
|
parsed,
|
|
),
|
|
time: new Intl.DateTimeFormat('en-IN', { timeStyle: 'short' }).format(
|
|
parsed,
|
|
),
|
|
};
|
|
} |