2018-04-03 18:31:20 -05:00
|
|
|
<template>
|
2018-04-14 15:04:08 -05:00
|
|
|
<span>
|
|
|
|
<input v-if="useInput" class="text" type="text" readonly :value="friendlyString" />
|
|
|
|
<span v-else :title="fullString">{{ friendlyString }}</span>
|
|
|
|
</span>
|
2018-04-03 18:31:20 -05:00
|
|
|
</template>
|
|
|
|
|
2024-09-29 13:35:49 -05:00
|
|
|
<script setup>
|
2018-04-03 18:31:20 -05:00
|
|
|
|
2024-09-29 13:35:49 -05:00
|
|
|
import { computed } from "vue";
|
2018-04-13 23:32:34 -05:00
|
|
|
import DateTimeUtils from "../lib/DateTimeUtils";
|
|
|
|
|
2024-09-29 13:35:49 -05:00
|
|
|
const props = defineProps({
|
|
|
|
dateTime: {
|
|
|
|
required: true,
|
|
|
|
type: [Date, String]
|
2018-04-03 18:31:20 -05:00
|
|
|
},
|
|
|
|
|
2024-09-29 13:35:49 -05:00
|
|
|
showDate: {
|
|
|
|
required: false,
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
|
|
|
|
showTime: {
|
|
|
|
required: false,
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
|
|
|
|
useInput: {
|
|
|
|
required: false,
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const dateObj = computed(() => DateTimeUtils.toDate(props.dateTime));
|
|
|
|
const fullString = computed(() => DateTimeUtils.formatTimestamp(dateObj.value));
|
|
|
|
|
|
|
|
const friendlyString = computed(() => {
|
|
|
|
const parts = [];
|
|
|
|
if (props.showDate) {
|
|
|
|
parts.push(DateTimeUtils.formatDate(dateObj.value));
|
|
|
|
}
|
|
|
|
if (props.showTime) {
|
|
|
|
parts.push(DateTimeUtils.formatTime(dateObj.value, true));
|
2018-04-03 18:31:20 -05:00
|
|
|
}
|
2024-09-29 13:35:49 -05:00
|
|
|
return parts.join(" ");
|
|
|
|
});
|
2018-04-03 18:31:20 -05:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|