parent
240e8594cc
commit
d583cb2094
2 changed files with 5 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
import {createDateFromString} from '@/helpers/time/createDateFromString'
|
||||
import {format, formatDistance} from 'date-fns'
|
||||
import {format, formatDistanceToNow} from 'date-fns'
|
||||
import {enGB, de, fr, ru} from 'date-fns/locale'
|
||||
|
||||
const locales = {en: enGB, de, ch: de, fr, ru}
|
||||
|
@ -29,12 +29,8 @@ export const formatDateSince = (date, $t) => {
|
|||
|
||||
date = createDateFromString(date)
|
||||
|
||||
const currentDate = new Date()
|
||||
const distance = formatDistance(date, currentDate, {locale: locales[$t('date.locale')]})
|
||||
|
||||
if (date > currentDate) {
|
||||
return $t('date.in', {date: distance})
|
||||
}
|
||||
|
||||
return $t('date.ago', {date: distance})
|
||||
return formatDistanceToNow(date, {
|
||||
locale: locales[$t('date.locale')],
|
||||
addSuffix: true,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -796,8 +796,6 @@
|
|||
},
|
||||
"date": {
|
||||
"locale": "en",
|
||||
"in": "in {date}",
|
||||
"ago": "{date} ago",
|
||||
"altFormatLong": "j M Y H:i",
|
||||
"altFormatShort": "j M Y"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue