summaryrefslogtreecommitdiffstats
path: root/apps/comments/src/components/Moment.vue
blob: a91ed8b9ce6983b4c2e50179f2f31fdcf4b54644 (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
30
31
<!-- TODO: Move to vue components -->

<template>
	<span class="live-relative-timestamp" :data-timestamp="timestamp * 1000" :title="title">{{ formatted }}</span>
</template>

<script>
import moment from '@nextcloud/moment'

export default {
	name: 'Moment',
	props: {
		timestamp: {
			type: Number,
			required: true,
		},
		format: {
			type: String,
			default: 'LLL',
		},
	},
	computed: {
		title() {
			return moment.unix(this.timestamp).format(this.format)
		},
		formatted() {
			return moment.unix(this.timestamp).fromNow()
		},
	},
}
</script>