mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
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!
24 lines
470 B
Vue
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>
|