¤ñ¹ï·sÀÉ®× |
| | |
| | | import Vue from 'vue' |
| | | |
| | | Vue.filter('formatDate', (value: string): string => { |
| | | const date = new Date(value); |
| | | const today = new Date(); |
| | | |
| | | const isToday = (compareDate: Date): boolean => { |
| | | return compareDate.getFullYear() === today.getFullYear() |
| | | && compareDate.getMonth() === today.getMonth() |
| | | && compareDate.getDate() === today.getDate(); |
| | | }; |
| | | |
| | | const isThisYear = (compareDate: Date): boolean => { |
| | | return compareDate.getFullYear() === today.getFullYear(); |
| | | } |
| | | |
| | | if (!value) { |
| | | return 'å°ç¡ç´é'; |
| | | } |
| | | |
| | | if (isThisYear(date)) { |
| | | return isToday(date) |
| | | ? `ä»å¤© ${date.getHours()}:${date.getMinutes()}` |
| | | : `${date.getMonth() + 1}æ${date.getDate()}æ¥ ${date.getHours()}:${date.getMinutes()}`; |
| | | } else { |
| | | return `${date.getFullYear()}å¹´${date.getMonth() + 1}æ${date.getDate()}æ¥ ${date.getHours()}:${date.getMinutes()}`; |
| | | } |
| | | |
| | | }) |