UNPKG

@ozen-ui/kit

Version:

React component library

27 lines (26 loc) 870 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatDateToString = void 0; var formatDateToString = function (date, steps) { if (!date) { return ''; } var hasYearsStep = steps.includes('years'); var hasMonthsStep = steps.includes('months'); var hasDaysStep = steps.includes('days'); var parts = []; if (hasDaysStep) { var day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date); parts.push(day); } if (hasMonthsStep) { var month = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(date); parts.push(month); } if (hasYearsStep) { var year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date); parts.push(year); } return parts.join('.'); }; exports.formatDateToString = formatDateToString;