roschaefer b2dccfb51c refactor: improve locale imports
While refactoring the login form component I found many inconsistent
ways of importing the list of locales. So I decided to refactor the
imports altogether. Don't use `process.env` to import locales!
2019-10-15 16:41:33 +02:00

24 lines
470 B
Vue

<template>
<span>{{ relativeDateTime }}</span>
</template>
<script>
import { getDateFnsLocale } from '~/locales'
import formatRelative from 'date-fns/formatRelative'
export default {
name: 'HcRelativeDateTime',
props: {
dateTime: {
type: [Date, String],
required: true,
},
},
computed: {
relativeDateTime() {
return formatRelative(new Date(this.dateTime), new Date(), { locale: getDateFnsLocale(this) })
},
},
}
</script>