@@ -53,6 +53,7 @@ import { vTooltip } from '@core/directives/tooltip.directive'
53
53
import type { Message, Task, TaskStatus } from '@core/types/task.type.ts'
54
54
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
55
55
import { useTimeAgo } from '@vueuse/core'
56
+ import type { UseTimeAgoMessages } from '@vueuse/core'
56
57
import { computed } from 'vue'
57
58
import { useI18n } from 'vue-i18n'
58
59
@@ -65,21 +66,23 @@ const { t } = useI18n()
65
66
66
67
const taskTimeStatus = computed(() => task.end ?? task.start ?? new Date())
67
68
69
+ const messages: UseTimeAgoMessages = {
70
+ justNow: t('just-now'),
71
+ past: (n: string) => (/\d/.test(n) ? t('ago', [n]) : n),
72
+ future: (n: string) => (/\d/.test(n) ? t('in', [n]) : n),
73
+ month: (n, past) => (n === 1 ? (past ? t('last-month') : t('next-month')) : `${n} ${t(`month${n > 1 ? 's' : ''}`)}`),
74
+ year: (n, past) => (n === 1 ? (past ? t('last-year') : t('next-year')) : `${n} ${t(`year${n > 1 ? 's' : ''}`)}`),
75
+ day: (n, past) => (n === 1 ? (past ? t('yesterday') : t('tomorrow')) : `${n} ${t(`day${n > 1 ? 's' : ''}`)}`),
76
+ week: (n, past) => (n === 1 ? (past ? t('last-week') : t('next-week')) : `${n} ${t(`week${n > 1 ? 's' : ''}`)}`),
77
+ hour: n => `${n} ${t(`hour${n > 1 ? 's' : ''}`)}`,
78
+ minute: n => `${n} ${t(`minute${n > 1 ? 's' : ''}`)}`,
79
+ second: n => `${n} ${t(`second${n > 1 ? 's' : ''}`)}`,
80
+ invalid: 'Invalid',
81
+ }
82
+
68
83
const timeAgo = useTimeAgo(taskTimeStatus, {
69
84
fullDateFormatter: (date: Date) => date.toLocaleDateString(),
70
- messages: {
71
- justNow: t('just-now'),
72
- past: (n: any) => (n.match(/\d/) ? t('ago', [n]) : n),
73
- future: (n: any) => (n.match(/\d/) ? t('in', [n]) : n),
74
- month: (n, past) =>
75
- n === 1 ? (past ? t('last-month') : t('next-month')) : `${n} ${t(`month${n > 1 ? 's' : ''}`)}`,
76
- year: (n, past) => (n === 1 ? (past ? t('last-year') : t('next-year')) : `${n} ${t(`year${n > 1 ? 's' : ''}`)}`),
77
- day: (n, past) => (n === 1 ? (past ? t('yesterday') : t('tomorrow')) : `${n} ${t(`day${n > 1 ? 's' : ''}`)}`),
78
- week: (n, past) => (n === 1 ? (past ? t('last-week') : t('next-week')) : `${n} ${t(`week${n > 1 ? 's' : ''}`)}`),
79
- hour: n => `${n} ${t(`hour${n > 1 ? 's' : ''}`)}`,
80
- minute: n => `${n} ${t(`minute${n > 1 ? 's' : ''}`)}`,
81
- second: n => `${n} ${t(`second${n > 1 ? 's' : ''}`)}`,
82
- },
85
+ messages,
83
86
})
84
87
85
88
const taskIsComplete = computed(() => {
0 commit comments