UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

44 lines (43 loc) 1.36 kB
import r from "dayjs"; function d(e, a) { const t = r(e, a); return r(e).isValid() ? r(e) : t.isValid() ? t : null; } function g(e, a) { const t = r(e, a); return r(e).isValid() ? r(e).format(a) : t.isValid() ? t.format(a) : ""; } function p(e) { const [a, t] = e; return !(!a || !t) && a.isValid() && t.isValid(); } function y(e, a = 15, t = 1) { const i = [], s = typeof e == "number" ? e : (e == null ? void 0 : e.getFullYear()) ?? 1970, u = (l = a, (n = s) === 0 ? l : ((n - 1) % l + l) % l + 1); var n, l; for (let o = s - (u - 1); o <= s + a - u; o += t) i.push(o); return i; } function c(e, a) { return new Date(e, a + 1, 0).getDate(); } function D(e, a) { const t = c(e, a), i = c(e, a - 1), s = []; for (let n = i - new Date(e, a, 1).getDay() + 1; n <= i; n++) s.push({ day: n, value: +new Date(e, a - 1, n), isRange: !1, isSelected: !1, type: "prev" }); for (let n = 1; n <= t; n++) s.push({ day: n, value: +new Date(e, a, n), isRange: !1, isSelected: !1, type: "current" }); const u = 7 - s.length % 7; if (u !== 7) for (let n = 1; n <= u; n++) s.push({ day: n, value: +new Date(e, a + 1, n), isRange: !1, isSelected: !1, type: "next" }); return s; } export { p as checkRangeValue, g as dayjsToString, c as getDayLength, y as getYears, d as normalizeDayjsValue, D as setDateList };