Presupuestador_web/shared/lib/utilities/helpers.ts
2024-10-03 16:23:46 +02:00

13 lines
462 B
TypeScript

export const adjustPrecision = ({ amount, scale }: { amount: number; scale: number }) => {
const factor = 10 ** scale;
return Number(amount) / factor;
};
export const formatDateToYYYYMMDD = (date: Date): string => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0"); // Los meses van de 0 a 11, por lo que sumamos 1
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
};