From f19e5267cc23b1c714dc746239864f33ed715dd9 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 05 十二月 2025 17:55:02 +0800
Subject: [PATCH] 完成地图制作任务功能初版

---
 src/utils/time-util.js |   96 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/src/utils/time-util.js b/src/utils/time-util.js
index 951116b..3852869 100644
--- a/src/utils/time-util.js
+++ b/src/utils/time-util.js
@@ -1,39 +1,105 @@
-import dayjs from "dayjs";
+import dayjs from 'dayjs';
 
 export default {
   format(date, template) {
-    return dayjs(date).format(template)
+    return dayjs(date).format(template);
   },
 
-  formatH(date){
+  formatH(date) {
     if (date) {
-      return this.format(date, 'HH:mm:ss')
+      return this.format(date, 'HH:mm:ss');
     } else {
-      return '--:--:--'
+      return '--:--:--';
     }
   },
 
-  formatYM(date){
+  formatYM(date) {
     if (date) {
-      return this.format(date, 'YYYY-MM')
+      return this.format(date, 'YYYY-MM');
     } else {
-      return '----/--'
+      return '----/--';
     }
   },
 
-  formatYMD(date){
+  formatYMD(date) {
     if (date) {
-      return this.format(date, 'YYYY-MM-DD')
+      return this.format(date, 'YYYY-MM-DD');
     } else {
-      return '----/--/--'
+      return '----/--/--';
     }
   },
 
-  formatYMDH(date){
+  formatYMDHM(date) {
     if (date) {
-      return this.format(date, 'YYYY-MM-DD HH:mm:ss')
+      return this.format(date, 'YYYY-MM-DD HH:mm');
     } else {
-      return '----/--/-- --:--:--'
+      return '----/--/-- --:--';
     }
   },
-}
\ No newline at end of file
+
+  formatYMDHMS(date) {
+    if (date) {
+      return this.format(date, 'YYYY-MM-DD HH:mm:ss');
+    } else {
+      return '----/--/-- --:--:--';
+    }
+  },
+
+  formatDateFromExcel(num, format) {
+    const old = num - 1;
+    const t = Math.round((old - Math.floor(old)) * 24 * 60 * 60);
+    const time = new Date(1900, 0, old, 0, 0, t);
+    const year = time.getFullYear();
+    const month = time.getMonth() + 1;
+    const date = time.getDate();
+    return dayjs(
+      year +
+      format +
+      (month < 10 ? '0' + month : month) +
+      format +
+      (date < 10 ? '0' + date : date)
+    );
+  },
+
+  /**
+   * 灏嗙鏁拌浆鎹负涓枃鎻忚堪鏍煎紡
+   * @param {number} seconds - 绉掓暟
+   * @returns {string} 涓枃鏃堕棿鎻忚堪
+   */
+  formatSecondsToChinese(seconds) {
+    if (!seconds || seconds < 0 || isNaN(seconds)) {
+      return '--';
+    }
+    
+    // 瀹氫箟鏃堕棿鍗曚綅鍜屽搴旂殑绉掓暟
+    const units = [
+      { unit: '澶�', value: 24 * 60 * 60 },
+      { unit: '灏忔椂', value: 60 * 60 },
+      { unit: '鍒嗛挓', value: 60 },
+      { unit: '绉�', value: 1 }
+    ];
+    
+    let remainingSeconds = Math.floor(seconds);
+    let result = '';
+    
+    // 閬嶅巻鏃堕棿鍗曚綅锛岃绠楁瘡涓崟浣嶇殑鏁伴噺
+    for (const { unit, value } of units) {
+      if (remainingSeconds >= value) {
+        const count = Math.floor(remainingSeconds / value);
+        result += `${count}${unit}`;
+        remainingSeconds %= value;
+        
+        // // 濡傛灉鍓╀綑绉掓暟涓�0锛屼笖宸茬粡鏈夌粨鏋滐紝灏卞彲浠ョ粨鏉熶簡
+        // if (remainingSeconds === 0 && result) {
+        //   break;
+        // }
+        // 濡傛灉宸茬粡鏈夌粨鏋滐紝灏卞彲浠ョ粨鏉熶簡
+        if (result) {
+          break;
+        }
+      }
+    }
+    
+    return result;
+  }
+};
\ No newline at end of file

--
Gitblit v1.9.3