2021-06-30 13:04:58 +00:00
|
|
|
<template>
|
|
|
|
<span>{{ displayText }}</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import dayjs from "dayjs";
|
2021-07-18 01:10:15 +00:00
|
|
|
import relativeTime from "dayjs/plugin/relativeTime"
|
2021-07-27 17:47:13 +00:00
|
|
|
import utc from "dayjs/plugin/utc"
|
|
|
|
import timezone from "dayjs/plugin/timezone" // dependent on utc plugin
|
2021-06-30 18:02:54 +00:00
|
|
|
dayjs.extend(utc)
|
|
|
|
dayjs.extend(timezone)
|
2021-06-30 13:04:58 +00:00
|
|
|
dayjs.extend(relativeTime)
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: String,
|
2021-07-26 14:53:07 +00:00
|
|
|
dateOnly: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-06-30 13:04:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
displayText() {
|
2021-07-26 14:53:07 +00:00
|
|
|
if (this.value !== undefined && this.value !== "") {
|
|
|
|
let format = "YYYY-MM-DD HH:mm:ss";
|
|
|
|
if (this.dateOnly) {
|
|
|
|
format = "YYYY-MM-DD";
|
|
|
|
}
|
|
|
|
return dayjs.utc(this.value).tz(this.$root.timezone).format(format);
|
|
|
|
}
|
2021-07-27 17:47:13 +00:00
|
|
|
|
|
|
|
return "";
|
2021-06-30 13:04:58 +00:00
|
|
|
},
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
2021-06-30 13:04:58 +00:00
|
|
|
}
|
|
|
|
</script>
|