From d1ccf7e1835b3c583da16d90a286e749d5e27c84 Mon Sep 17 00:00:00 2001
From: zmc <zmc_li@foxmail.com>
Date: 星期四, 07 十二月 2023 14:15:20 +0800
Subject: [PATCH] 修改无数据时段的算法

---
 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