|
|
@@ -141,10 +141,9 @@
|
|
|
<font-awesome-icon :icon="['fas', 'calendar']" class="icon mr-2" />
|
|
|
</td>
|
|
|
<td>
|
|
|
- <span v-if="event.datetimeStart && event.datetimeEnd">
|
|
|
- {{ new Date(event.datetimeStart).toLocaleString() }} ~ {{ new Date(event.datetimeEnd).toLocaleString() }}
|
|
|
+ <span>
|
|
|
+ {{ formatDateIntervalFor(new Date(event.datetimeStart), new Date(event.datetimeEnd)) }}
|
|
|
</span>
|
|
|
- <span v-else>{{ new Date(event.datetimeStart).toLocaleString() }}</span>
|
|
|
</td>
|
|
|
</tr>
|
|
|
|
|
|
@@ -193,8 +192,8 @@
|
|
|
<script lang="ts">
|
|
|
import Vue from 'vue'
|
|
|
import EventsProvider from "~/services/data/EventsProvider"
|
|
|
-import {today, todayIso, formatIso, formatIsoDate} from '@/services/utils/date'
|
|
|
-import { reformatDate, addDays, nextSunday, addMonths } from "date-fns";
|
|
|
+import {today, todayIso, formatIso} from '@/services/utils/date'
|
|
|
+import locale from 'date-fns/locale/fr'
|
|
|
|
|
|
const defaultDateRange: DateRange = { start: '', end: '' }
|
|
|
|
|
|
@@ -219,7 +218,7 @@ export default Vue.extend({
|
|
|
null,
|
|
|
this.dateRangeFilter.start,
|
|
|
this.dateRangeFilter.end,
|
|
|
- null,
|
|
|
+ this.locationFilter,
|
|
|
this.page,
|
|
|
this.itemsPerPage
|
|
|
).then(
|
|
|
@@ -246,20 +245,20 @@ export default Vue.extend({
|
|
|
// Cette semaine
|
|
|
const week_preset: DateRangePreset = {
|
|
|
label: this.$t('next_week').toString(),
|
|
|
- range: {start: todayIso(), end: formatIso(addDays(today(), 7))}
|
|
|
+ range: {start: todayIso(), end: formatIso(this.$dateFns.addDays(today(), 7))}
|
|
|
}
|
|
|
|
|
|
// Ce week-end
|
|
|
- const sunday: Date = nextSunday(today())
|
|
|
+ const sunday: Date = this.$dateFns.nextSunday(today())
|
|
|
const weekend_preset: DateRangePreset = {
|
|
|
label: this.$t('next_weekend').toString(),
|
|
|
- range: {start: formatIso(addDays(sunday, -2)), end: formatIso(sunday)}
|
|
|
+ range: {start: formatIso(this.$dateFns.addDays(sunday, -2)), end: formatIso(sunday)}
|
|
|
}
|
|
|
|
|
|
// Ce mois
|
|
|
const month_preset: DateRangePreset = {
|
|
|
label: this.$t('next_month').toString(),
|
|
|
- range: {start: todayIso(), end: formatIso(addMonths(today(), 1))}
|
|
|
+ range: {start: todayIso(), end: formatIso(this.$dateFns.addMonths(today(), 1))}
|
|
|
}
|
|
|
|
|
|
return [today_preset, week_preset, weekend_preset, month_preset]
|
|
|
@@ -305,9 +304,36 @@ export default Vue.extend({
|
|
|
enhancedAutocompleteFilter (_: any, queryText: string, itemText: string): boolean {
|
|
|
return normalize(itemText).includes(normalize(queryText))
|
|
|
},
|
|
|
- formatDatetime(date: string): string {
|
|
|
- console.log(date)
|
|
|
- return reformatDate(date, 'yyyy-MM-DD[T]HH:mm:ssZZ', 'dd/MM/yyyy hh:mm')
|
|
|
+ formatDate(date: Date, short = true): string {
|
|
|
+ return short ? this.$dateFns.format(date, 'dd/MM/yyyy') : this.$dateFns.format(date, 'dd MMM yyyy', {locale: locale})
|
|
|
+ },
|
|
|
+ formatTime(date: Date): string {
|
|
|
+ return this.$dateFns.format(date, 'HH:mm')
|
|
|
+ },
|
|
|
+ formatDateTime(date: Date): string {
|
|
|
+ return this.formatDate(date) + ' ' + this.$t('on_hour') + ' ' + this.formatTime(date)
|
|
|
+ },
|
|
|
+ formatDateIntervalFor(dateStart: Date | null = null, dateEnd: Date | null = null): string {
|
|
|
+ if (dateStart === null && dateEnd !== null)
|
|
|
+ {
|
|
|
+ return this.formatDateTime(dateEnd)
|
|
|
+ }
|
|
|
+ else if (dateEnd === null && dateStart !== null) {
|
|
|
+ return this.formatDateTime(dateStart)
|
|
|
+ }
|
|
|
+ else if (dateStart !== null && dateEnd !== null) {
|
|
|
+ if (dateStart === dateEnd) {
|
|
|
+ return this.formatDateTime(dateStart)
|
|
|
+ }
|
|
|
+ else if (this.$dateFns.isSameDay(dateStart, dateEnd)) {
|
|
|
+ return this.$t('on_day') + ' ' + this.formatDate(dateStart, false) + ', ' +
|
|
|
+ this.$t('from_hour') + ' ' + this.formatTime(dateStart) + ' ' + this.$t('to_hour') + ' ' + this.formatTime(dateEnd)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return this.$t('from_day') + ' ' + this.formatDateTime(dateStart) + ' ' + this.$t('to_day') + ' ' + this.formatDateTime(dateEnd)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ""
|
|
|
}
|
|
|
}
|
|
|
})
|