RTOPP / frontend /src /utils /format.ts
vinay-pepakayala's picture
Upload 84 files
a247911 verified
Raw
History Blame Contribute Delete
453 Bytes
export function currency(value: number | string | undefined) {
const numberValue = Number(value ?? 0);
return new Intl.NumberFormat('en-IN', {
style: 'currency',
currency: 'INR',
maximumFractionDigits: 2
}).format(numberValue);
}
export function dateTime(value: string | undefined) {
if (!value) return '-';
return new Intl.DateTimeFormat('en-IN', {
dateStyle: 'medium',
timeStyle: 'short'
}).format(new Date(value));
}