akkoma-fe/src/components/chat_message_date/chat_message_date.vue
rinpatch 60a8a89f5b Use app locale with toLocaleString/toLocaleDateString
Fixes inconsistent date formatting when browser language is different
from PleromaFE language.
2021-01-21 20:31:54 +03:00

26 lines
576 B
Vue

<template>
<time>
{{ displayDate }}
</time>
</template>
<script>
import localeService from 'src/services/locale/locale.service.js'
export default {
name: 'Timeago',
props: ['date'],
computed: {
displayDate () {
const today = new Date()
today.setHours(0, 0, 0, 0)
if (this.date.getTime() === today.getTime()) {
return this.$t('display_date.today')
} else {
return this.date.toLocaleDateString(localeService.internalToBrowserLocale(this.$i18n.locale), { day: 'numeric', month: 'long' })
}
}
}
}
</script>