|
@@ -22,13 +22,18 @@ export function getRangeTime(val1: Time, val2: Time, type = 'YYYYMMDD'): string[
|
|
|
// 处理开始时间和结束时间
|
|
// 处理开始时间和结束时间
|
|
|
let startTime = fn(val1)
|
|
let startTime = fn(val1)
|
|
|
let endTime = fn(val2)
|
|
let endTime = fn(val2)
|
|
|
- if (moment(startTime).isAfter(moment(endTime))) {
|
|
|
|
|
- [startTime, endTime] = [endTime, startTime]
|
|
|
|
|
|
|
+ const isSame = () => moment(startTime).isSame(moment(endTime))
|
|
|
|
|
+ if (isSame()) {
|
|
|
|
|
+ return [startTime, startTime]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (moment(startTime).isAfter(moment(endTime))) {
|
|
|
|
|
+ [startTime, endTime] = [endTime, startTime]
|
|
|
|
|
+ }
|
|
|
|
|
+ while (!isSame()) {
|
|
|
|
|
+ result.push(startTime)
|
|
|
|
|
+ startTime = moment(startTime).add(1, 'd').format(type)
|
|
|
|
|
+ }
|
|
|
|
|
+ result.push(endTime)
|
|
|
|
|
+ return result
|
|
|
}
|
|
}
|
|
|
- while (!moment(startTime).isSame(moment(endTime))) {
|
|
|
|
|
- result.push(startTime)
|
|
|
|
|
- startTime = moment(startTime).add(1, 'd').format(type)
|
|
|
|
|
- }
|
|
|
|
|
- result.push(endTime)
|
|
|
|
|
- return result
|
|
|
|
|
}
|
|
}
|