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 |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/src/utils/time-util.js b/src/utils/time-util.js
index dec4073..3852869 100644
--- a/src/utils/time-util.js
+++ b/src/utils/time-util.js
@@ -29,7 +29,15 @@
     }
   },
 
-  formatYMDH(date) {
+  formatYMDHM(date) {
+    if (date) {
+      return this.format(date, 'YYYY-MM-DD HH:mm');
+    } else {
+      return '----/--/-- --:--';
+    }
+  },
+
+  formatYMDHMS(date) {
     if (date) {
       return this.format(date, 'YYYY-MM-DD HH:mm:ss');
     } else {
@@ -44,12 +52,54 @@
     const year = time.getFullYear();
     const month = time.getMonth() + 1;
     const date = time.getDate();
-    return (
+    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