21 lines
560 B
TypeScript
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);
|
|
};
|