2021-06-30 09:04:58 -04:00
|
|
|
<template>
|
|
|
|
<span>{{ displayText }}</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import dayjs from "dayjs";
|
2021-07-17 21:10:15 -04:00
|
|
|
import relativeTime from "dayjs/plugin/relativeTime"
|
2021-07-27 13:47:13 -04:00
|
|
|
import utc from "dayjs/plugin/utc"
|
|
|
|
import timezone from "dayjs/plugin/timezone" // dependent on utc plugin
|
2021-06-30 14:02:54 -04:00
|
|
|
dayjs.extend(utc)
|
|
|
|
dayjs.extend(timezone)
|
2021-06-30 09:04:58 -04:00
|
|
|
dayjs.extend(relativeTime)
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: String,
|
2021-07-26 10:53:07 -04:00
|
|
|
dateOnly: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-06-30 09:04:58 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
displayText() {
|
2021-08-17 04:41:12 -04:00
|
|
|
if (this.dateOnly) {
|
|
|
|
return this.$root.date(this.value);
|
|
|
|
} else {
|
|
|
|
return this.$root.datetime(this.value);
|
2021-07-26 10:53:07 -04:00
|
|
|
}
|
2021-06-30 09:04:58 -04:00
|
|
|
},
|
2021-07-27 13:47:13 -04:00
|
|
|
},
|
2021-06-30 09:04:58 -04:00
|
|
|
}
|
|
|
|
</script>
|