From c24a5a2a99515b365ebc343b04538bb862790de1 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 21 十二月 2023 11:44:22 +0800 Subject: [PATCH] Merge branch 'feature-code-refactoring' and 'feature-002' --- src/utils/time.js | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/src/utils/time.js b/src/utils/time.js index c416595..738e1d9 100644 --- a/src/utils/time.js +++ b/src/utils/time.js @@ -142,5 +142,38 @@ result.push(temp) } return result + }, + + /** + * 鎵惧埌鍦ㄧ粰瀹氱殑寮�濮嬫椂闂碽t鍜岀粨鏉熸椂闂磂t涔嬮棿缂哄け鐨勬椂闂村尯闂� + * @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 } } -- Gitblit v1.9.3