UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

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