From 90e6cb94e9c9a4d055a0983c9c7386daa48f61f9 Mon Sep 17 00:00:00 2001
From: HelenHuang <LinHuang@pollex.com.tw>
Date: 星期四, 09 六月 2022 15:45:03 +0800
Subject: [PATCH] TODO#139893 [ FAQ 常見問題 -我進行預約後,顧問會用甚麼方式聯繫我? ] 文案調整

---
 PAMapp/plugins/filters/date.filter.ts |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/PAMapp/plugins/filters/date.filter.ts b/PAMapp/plugins/filters/date.filter.ts
index d563e18..daa1f12 100644
--- a/PAMapp/plugins/filters/date.filter.ts
+++ b/PAMapp/plugins/filters/date.filter.ts
@@ -1,8 +1,18 @@
 import Vue from 'vue'
 
-Vue.filter('formatDate', (value: string): string => {
-  const date = new Date(value);
+Vue.filter('formatDate', (value: string | Date | null): string => {
+  let date: Date;
   const today = new Date();
+
+  if (!value) {
+    return '撠蝝����';
+  };
+
+  if (typeof value === 'string') {
+    date = new Date(value);
+  } else {
+    date = value;
+  };
 
   const isToday = (compareDate: Date): boolean => {
     return compareDate.getFullYear() === today.getFullYear()
@@ -12,18 +22,16 @@
 
   const isThisYear = (compareDate: Date): boolean => {
     return compareDate.getFullYear() === today.getFullYear();
-  }
+  };
 
-  if (!value) {
-    return '撠蝝����';
-  }
+  const minutes = date.getMinutes() > 9 ?  date.getMinutes() : `0${date.getMinutes()}`;
 
   if (isThisYear(date)) {
     return isToday(date)
-          ? `隞予 ${date.getHours()}:${date.getMinutes()}`
-          : `${date.getMonth() + 1}���${date.getDate()}� ${date.getHours()}:${date.getMinutes()}`;
+          ? `隞予 ${date.getHours()}:${minutes}`
+          : `${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:${minutes}`;
   } else {
-    return `${date.getFullYear()}撟�${date.getMonth() + 1}���${date.getDate()}� ${date.getHours()}:${date.getMinutes()}`;
-  }
+    return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:${minutes}`;
+  };
 
 })

--
Gitblit v1.8.0