budget-view-finance/src/utils/formatters.ts
2025-06-11 00:33:12 +00:00

21 lines
560 B
TypeScript

export const formatCurrency = (value: number): string => {
return new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL',
}).format(value);
};
export const formatDate = (date: string | Date): string => {
const dateObj = typeof date === 'string' ? new Date(date) : date;
return dateObj.toLocaleDateString('pt-BR');
};
export const formatPercent = (value: number): string => {
return new Intl.NumberFormat('pt-BR', {
style: 'percent',
minimumFractionDigits: 1,
maximumFractionDigits: 1,
}).format(value / 100);
};