summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/user_date.vue
blob: 38dddbf72c208047b45df7f237a9f22c177bf184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script>
import { formatDate } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale';
import { SHORT_DATE_FORMAT } from '../constants';

export default {
  props: {
    date: {
      type: String,
      required: false,
      default: null,
    },
  },
  computed: {
    formattedDate() {
      const { date } = this;
      if (date === null) {
        return __('Never');
      }
      return formatDate(new Date(date), SHORT_DATE_FORMAT);
    },
  },
};
</script>
<template>
  <span>
    {{ formattedDate }}
  </span>
</template>