@antdv/pro-utils
Version:
@antdv/pro-utils
24 lines (23 loc) • 664 B
JavaScript
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import { isNil } from "../is/index.mjs";
dayjs.extend(customParseFormat);
const isMoment = (value) => !!(value == null ? void 0 : value._isAMomentObject);
function parseValueToDay(value, formatter) {
if (isNil(value) || dayjs.isDayjs(value) || isMoment(value)) {
if (isMoment(value)) {
return dayjs(value);
}
return value;
}
if (Array.isArray(value)) {
return value.map(
(v) => parseValueToDay(v, formatter)
);
}
if (typeof value === "number") return dayjs(value);
return dayjs(value, formatter);
}
export {
parseValueToDay
};