calendar/src/components/AppNavigation/CalendarList/Moment.vue

36 lines
679 B
Vue

<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: [Date, Number],
required: true,
},
format: {
type: String,
default: 'LLL',
},
},
computed: {
title() {
return moment.unix(this.numericTimestamp).format(this.format)
},
formatted() {
return moment.unix(this.numericTimestamp).fromNow()
},
numericTimestamp() {
if (this.timestamp instanceof Date) {
return this.timestamp.getTime() / 1000
}
return this.timestamp
},
},
}
</script>