import dayjs from 'dayjs' // 获取指定时间范围内的所有日期 export function getRangeAllTime(startDate: string, endDate: string) { console.log(`${startDate}-${endDate}`) const dates = [] let currentDate = dayjs(startDate) const formattedEndDate = dayjs(endDate).format('YYYY-MM-DD') while (currentDate.format('YYYY-MM-DD') <= formattedEndDate) { dates.push(currentDate.format('YYYY-MM-DD')) currentDate = currentDate.add(1, 'day') } return dates } // 获取指定时间范围内的所有月份 export function getRangeAllMonth(startDate: string, endDate: string) { console.log(`${startDate}-${endDate}`) const dates = [] let currentDate = dayjs(startDate) const formattedEndDate = dayjs(endDate).format('YYYY-MM') while (currentDate.format('YYYY-MM') <= formattedEndDate) { dates.push(currentDate.format('YYYY-MM')) currentDate = currentDate.add(1, 'month') } return dates }