diff --git a/aleksis/core/frontend/components/calendar/BaseCalendarFeedDetails.vue b/aleksis/core/frontend/components/calendar/BaseCalendarFeedDetails.vue index a9dc64fdb9bfd5713d68d2ebf926b78ad255ea51..4278c39f483682d0c2da21370ed2a06d9256ee7b 100644 --- a/aleksis/core/frontend/components/calendar/BaseCalendarFeedDetails.vue +++ b/aleksis/core/frontend/components/calendar/BaseCalendarFeedDetails.vue @@ -26,13 +26,31 @@ </v-list-item-icon> <v-list-item-content> <v-list-item-title> - <span v-if="selectedEvent.start !== selectedEvent.end"> + <span + v-if=" + selectedEvent.allDay && + selectedEvent.start.getTime() === selectedEvent.end.getTime() + " + > + {{ $d(selectedEvent.start, "short") }} + </span> + <span v-else-if="selectedEvent.allDay"> + {{ $d(selectedEvent.start, "short") }} – + {{ $d(selectedEvent.end, "short") }} + </span> + <span + v-else-if=" + dateWithoutTime(selectedEvent.start).getTime() === + dateWithoutTime(selectedEvent.end).getTime() + " + > {{ $d(selectedEvent.start, "shortDateTime") }} – - {{ $d(selectedEvent.end, "shortDateTime") }} + {{ $d(selectedEvent.end, "shortTime") }} </span> <span v-else> - {{ $d(selectedEvent.start, "shortDateTime") }}</span - > + {{ $d(selectedEvent.start, "shortDateTime") }} – + {{ $d(selectedEvent.end, "shortDateTime") }} + </span> </v-list-item-title> </v-list-item-content> </v-list-item> @@ -63,5 +81,12 @@ export default { name: "BaseCalendarFeedDetails", components: { CancelledCalendarStatusChip }, mixins: [calendarFeedDetailsMixin], + methods: { + dateWithoutTime(d) { + d = new Date(d); + d.setHours(0, 0, 0, 0); + return d; + }, + }, }; </script> diff --git a/aleksis/core/models.py b/aleksis/core/models.py index 3f6f6d915a4570855317de09939c980b25069949..4151d51b39d4cafac8ba91250a5ed64b8d4af50e 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -1562,11 +1562,15 @@ class CalendarEvent(CalendarEventMixin, ExtensiblePolymorphicModel): @classmethod def value_end_datetime( cls, reference_object: "CalendarEvent", request - ) -> Union[datetime, date]: + ) -> Union[datetime, date, None]: """Return the end datetime of the calendar event.""" if reference_object.datetime_end: return reference_object.datetime_end.astimezone(reference_object.timezone) - return reference_object.date_end + timedelta(days=1) + if reference_object.date_end == reference_object.date_start: + # Rule for all day events: If the event is only one day long, + # the end date has to be empty + return None + return reference_object.date_end @classmethod def value_rrule(cls, reference_object: "CalendarEvent", request) -> Optional[vRecur]: