| | |
| | | result.push(temp) |
| | | } |
| | | return result |
| | | }, |
| | | |
| | | /** |
| | | * 找到在给定的开始时间bt和结束时间et之间缺失的时间区间 |
| | | * @param:开始时间,结束时间,在这个时间范围内已有的时间(时间字符串数组) |
| | | * @returns: |
| | | */ |
| | | getMissingDays(bt, et, timeArr) { |
| | | // 存储缺失的时间区间 |
| | | const r = [] |
| | | const begin = dayjs(bt) |
| | | const end = dayjs(et) |
| | | // 开始时间 |
| | | let current = begin |
| | | |
| | | for (const time of timeArr) { |
| | | const currentTime = dayjs(time) |
| | | if (currentTime.isBefore(current)) { |
| | | continue |
| | | } |
| | | |
| | | if (currentTime.isAfter(current)) { |
| | | r.push([current.format('YYYY-MM-DD'), currentTime.format('YYYY-MM-DD')]) |
| | | } |
| | | |
| | | current = currentTime.add(1, 'day') |
| | | } |
| | | |
| | | if (end.isAfter(current)) { |
| | | r.push([current.format('YYYY-MM-DD'), end.format('YYYY-MM-DD')]) |
| | | } |
| | | |
| | | return r |
| | | } |
| | | } |