@malga-checkout/core
Version:
Core components for Malga Checkout
22 lines (19 loc) • 758 B
JavaScript
;
const formatISODate = (currentDate) => {
const year = currentDate.toLocaleString('default', { year: 'numeric' });
const month = currentDate.toLocaleString('default', { month: '2-digit' });
const day = currentDate.toLocaleString('default', { day: '2-digit' });
return `${year}-${month}-${day}`;
};
const formatDate = (currentDate) => {
const formattedDate = new Intl.DateTimeFormat('pt-BR');
return formattedDate.format(currentDate);
};
const parseDate = (currentDate) => {
const [year, month, day] = currentDate.split('-');
const currentMonth = parseInt(month) - 1;
return [year, currentMonth, day];
};
exports.formatDate = formatDate;
exports.formatISODate = formatISODate;
exports.parseDate = parseDate;