import dayjs from "dayjs"; /** 开始日期禁用配置 */ export function genStartDateDisabledOptions(endDate: string, limit: number = 0) { return { disabledDate: (time: Date) => { if (!endDate) return false; const currentDate = dayjs(time); const baseOption = currentDate.isAfter(dayjs(endDate), 'day'); if (!limit) { return baseOption } return baseOption || currentDate.isBefore(dayjs(endDate).subtract(limit - 1, 'day'), 'day'); } }; } /** 结束日期禁用配置 */ export function genEndDateDisabledOptions(startDate: string, limit: number = 0) { return { disabledDate: (time: Date) => { if (!startDate) return false; const currentDate = dayjs(time); const baseOption = currentDate.isBefore(dayjs(startDate), 'day'); if (!limit) { return baseOption } return baseOption || currentDate.isAfter(dayjs(startDate).add(limit - 1, 'day'), 'day'); } }; }