From 89f7eba16f36d75e11c2b49e3ea1624787203606 Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期三, 17 十一月 2021 12:55:17 +0800
Subject: [PATCH] update: 推薦顧問輪播

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

diff --git a/PAMapp/plugins/filters/date.filter.ts b/PAMapp/plugins/filters/date.filter.ts
index 7c3670c..281c148 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,7 +22,7 @@
 
   const isThisYear = (compareDate: Date): boolean => {
     return compareDate.getFullYear() === today.getFullYear();
-  }
+  };
 
   if (isThisYear(date)) {
     return isToday(date)
@@ -20,6 +30,6 @@
           : `${date.getMonth() + 1}���${date.getDate()}� ${date.getHours()}:${date.getMinutes()}`;
   } else {
     return `${date.getFullYear()}撟�${date.getMonth() + 1}���${date.getDate()}� ${date.getHours()}:${date.getMinutes()}`;
-  }
+  };
 
 })

--
Gitblit v1.8.0