54 lines
1001 B
Vue
54 lines
1001 B
Vue
<template>
|
|
<span :title="fullString">{{ friendlyString }}</span>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import DateTimeUtils from "../lib/DateTimeUtils";
|
|
|
|
export default {
|
|
props: {
|
|
dateTime: {
|
|
required: true,
|
|
type: [Date, String]
|
|
},
|
|
|
|
showDate: {
|
|
required: false,
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
|
|
showTime: {
|
|
required: false,
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
},
|
|
|
|
computed: {
|
|
dateObj() {
|
|
return DateTimeUtils.toDate(this.dateTime);
|
|
},
|
|
|
|
friendlyString() {
|
|
const parts = [];
|
|
if (this.showDate) {
|
|
parts.push(DateTimeUtils.formatDate(this.dateObj));
|
|
}
|
|
if (this.showTime) {
|
|
parts.push(DateTimeUtils.formatTime(this.dateObj, true));
|
|
}
|
|
return parts.join(" ");
|
|
},
|
|
|
|
fullString() {
|
|
return DateTimeUtils.formatTimestamp(this.dateObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
</style> |