2019-04-03 15:29:03 +00:00
|
|
|
<template>
|
2019-09-09 07:31:08 +00:00
|
|
|
<span v-if="!endsOn">{{ beginsOn | formatDateTimeString }}</span>
|
2019-09-12 09:34:01 +00:00
|
|
|
<span v-else-if="isSameDay()">
|
|
|
|
{{ $t('The {date} from {startTime} to {endTime}', {date: formatDate(beginsOn), startTime: formatTime(beginsOn), endTime: formatTime(endsOn)}) }}
|
|
|
|
</span>
|
|
|
|
<span v-else-if="endsOn">
|
|
|
|
{{ $t('From the {startDate} at {startTime} to the {endDate} at {endTime}',
|
|
|
|
{startDate: formatDate(beginsOn), startTime: formatTime(beginsOn), endDate: formatDate(endsOn), endTime: formatTime(endsOn)}) }}
|
|
|
|
</span>
|
2019-04-03 15:29:03 +00:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class EventFullDate extends Vue {
|
|
|
|
@Prop({ required: true }) beginsOn!: string;
|
|
|
|
@Prop({ required: false }) endsOn!: string;
|
|
|
|
|
|
|
|
formatDate(value) {
|
2019-09-09 07:31:08 +00:00
|
|
|
if (!this.$options.filters) return;
|
|
|
|
return this.$options.filters.formatDateString(value);
|
2019-04-03 15:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
formatTime(value) {
|
2019-09-09 07:31:08 +00:00
|
|
|
if (!this.$options.filters) return;
|
|
|
|
return this.$options.filters.formatTimeString(value);
|
2019-04-03 15:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
isSameDay() {
|
|
|
|
const sameDay = ((new Date(this.beginsOn)).toDateString()) === ((new Date(this.endsOn)).toDateString());
|
|
|
|
return this.endsOn && sameDay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|