将日期区间拆分成单个日期数组
function getDateList(start, end, type) {
const startTime = getDate(start, type);
const endTime = getDate(end, type);
const arr = [];
do {
const year = startTime.getFullYear();
const month = startTime.getMonth() + 1 < 10 ?
"0" + (startTime.getMonth() + 1) : startTime.getMonth() + 1;
const day = startTime.getDate() < 10 ?
"0" + startTime.getDate() : startTime.getDate();
type === 'date' ? startTime.setDate(startTime.getDate() + 1) && arr.push(year + "-" + month + "-" + day) :
startTime.setMonth(startTime.getMonth() + 1) && arr.push(year + "-" + month);
}
while ((endTime.getTime() - startTime.getTime()) >= 0)
return arr;
};
function getDate(datestr, type) {
const temp = datestr.split("-");
const date = type === 'date' ? new Date(temp[0], parseInt(temp[1]) - 1, temp[2]) :
new Date(temp[0], parseInt(temp[1]) - 1);
return date;
};