@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
23 lines (22 loc) • 1.01 kB
JavaScript
"use client";
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
//#region packages/@mantine/dates/src/utils/get-formatted-date/get-formatted-date.ts
function defaultDateFormatter({ type, date, locale, format, labelSeparator }) {
const formatDate = (value) => (0, dayjs.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);
}
//#endregion
exports.getFormattedDate = getFormattedDate;
//# sourceMappingURL=get-formatted-date.cjs.map