debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/user_date.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
727 B
Vue
Raw Normal View History

2021-03-11 19:13:27 +05:30
<script>
import { formatDate } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale';
2021-10-27 15:23:28 +05:30
import { SHORT_DATE_FORMAT, DATE_FORMATS } from '../constants';
2021-03-11 19:13:27 +05:30
export default {
props: {
date: {
type: String,
required: false,
default: null,
},
2021-10-27 15:23:28 +05:30
dateFormat: {
type: String,
required: false,
default: SHORT_DATE_FORMAT,
validator: (dateFormat) => DATE_FORMATS.includes(dateFormat),
},
2021-03-11 19:13:27 +05:30
},
computed: {
formattedDate() {
const { date } = this;
if (date === null) {
return __('Never');
}
2021-10-27 15:23:28 +05:30
return formatDate(new Date(date), this.dateFormat);
2021-03-11 19:13:27 +05:30
},
},
};
</script>
<template>
<span>
{{ formattedDate }}
</span>
</template>