@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
21 lines (20 loc) • 862 B
JavaScript
"use client";
import dayjs from "dayjs";
//#region packages/@mantine/dates/src/utils/get-formatted-date/get-formatted-date.ts
function defaultDateFormatter({ type, date, locale, format, labelSeparator }) {
const formatDate = (value) => dayjs(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
export { getFormattedDate };
//# sourceMappingURL=get-formatted-date.mjs.map