aboutsummaryrefslogtreecommitdiff
path: root/src/components/chat_message_date/chat_message_date.vue
blob: 98349b753c1470b91a3c31aba40012ce3a58466a (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
<template>
  <time>
    {{ displayDate }}
  </time>
</template>

<script>
import localeService from 'src/services/locale/locale.service.js'

export default {
  name: 'Timeago',
  props: ['date'],
  computed: {
    displayDate () {
      const today = new Date()
      today.setHours(0, 0, 0, 0)

      if (this.date.getTime() === today.getTime()) {
        return this.$t('display_date.today')
      } else {
        return this.date.toLocaleDateString(localeService.internalToBrowserLocale(this.$i18n.locale), { day: 'numeric', month: 'long' })
      }
    }
  }
}
</script>