@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
42 lines (36 loc) • 1.08 kB
JavaScript
'use client';
;
var dayjs = require('dayjs');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
function defaultDateFormatter({
type,
date,
locale,
format,
labelSeparator
}) {
const formatDate = (value) => dayjs__default.default(value).locale(locale).format(format);
if (type === "default") {
return date === null ? "" : formatDate(date);
}
if (type === "multiple") {
return date.map(formatDate).join(", ");
}
if (type === "range" && Array.isArray(date)) {
if (date[0] && date[1]) {
return `${formatDate(date[0])} ${labelSeparator} ${formatDate(date[1])}`;
}
if (date[0]) {
return `${formatDate(date[0])} ${labelSeparator} `;
}
return "";
}
return "";
}
function getFormattedDate({ formatter, ...others }) {
return (formatter || defaultDateFormatter)(others);
}
exports.defaultDateFormatter = defaultDateFormatter;
exports.getFormattedDate = getFormattedDate;
//# sourceMappingURL=get-formatted-date.cjs.map