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