2021-01-22 13:09:10 -05:00
|
|
|
<script>
|
|
|
|
import { formatDate } from '~/lib/utils/datetime_utility';
|
|
|
|
import { __ } from '~/locale';
|
2021-08-11 14:10:52 -04:00
|
|
|
import { SHORT_DATE_FORMAT, DATE_FORMATS } from '../constants';
|
2021-01-22 13:09:10 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
date: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2021-08-11 14:10:52 -04:00
|
|
|
dateFormat: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: SHORT_DATE_FORMAT,
|
|
|
|
validator: (dateFormat) => DATE_FORMATS.includes(dateFormat),
|
|
|
|
},
|
2021-01-22 13:09:10 -05:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
formattedDate() {
|
|
|
|
const { date } = this;
|
|
|
|
if (date === null) {
|
|
|
|
return __('Never');
|
|
|
|
}
|
2021-08-11 14:10:52 -04:00
|
|
|
return formatDate(new Date(date), this.dateFormat);
|
2021-01-22 13:09:10 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<span>
|
|
|
|
{{ formattedDate }}
|
|
|
|
</span>
|
|
|
|
</template>
|