From 2b897359149fde4d38e72c111dd6762d3c4ad332 Mon Sep 17 00:00:00 2001 From: Peter Thienel <thienel@data-quest.de> Date: Fri, 22 Mar 2024 09:27:53 +0000 Subject: [PATCH] =?UTF-8?q?Resolve:=20"Ganzt=C3=A4gige=20Termine=20=C3=BCb?= =?UTF-8?q?er=20mehrere=20Tage=20werden=20nicht=20als=20Ganztagstermine=20?= =?UTF-8?q?dargestellt"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3875 Merge request studip/studip!2731 --- lib/classes/calendar/EventData.class.php | 30 ++++++++++++++----- .../calendar/CalendarDateAssignment.class.php | 3 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/classes/calendar/EventData.class.php b/lib/classes/calendar/EventData.class.php index 82afe6f3b77..95e89b0ec6a 100644 --- a/lib/classes/calendar/EventData.class.php +++ b/lib/classes/calendar/EventData.class.php @@ -69,15 +69,29 @@ class EventData public function toFullcalendarEvent() { - //Note: The timezone must not be transmitted or - //the events may be shifted when there is a timezone - //or daylight saving time difference between the server - //and the client! - return [ + // Note: The timezone must not be transmitted or + // the events may be shifted when there is a timezone + // or daylight saving time difference between the server + // and the client! + // To display all-day events correctly in fullcalendar + // reduce the start and end to date without time and add one day + // to the end date... + if ($this->all_day) { + $fc_date = [ + 'allDay' => true, + 'start' => $this->begin->format('Y-m-d'), + 'end' => $this->end->modify('+1 day')->format('Y-m-d') + ]; + } else { + $fc_date = [ + 'allDay' => false, + 'start' => $this->begin->format('Y-m-d\TH:i:s'), + 'end' => $this->end->format('Y-m-d\TH:i:s') + ]; + } + + return $fc_date + [ 'resourceId' => $this->range_id, - 'start' => $this->begin->format('Y-m-d\TH:i:s'), - 'end' => $this->end->format('Y-m-d\TH:i:s'), - 'allDay' => $this->all_day, 'title' => $this->title, 'classNames' => $this->event_classes, 'textColor' => $this->text_colour, diff --git a/lib/models/calendar/CalendarDateAssignment.class.php b/lib/models/calendar/CalendarDateAssignment.class.php index 101cb9642b5..4e084c2436e 100644 --- a/lib/models/calendar/CalendarDateAssignment.class.php +++ b/lib/models/calendar/CalendarDateAssignment.class.php @@ -507,8 +507,7 @@ class CalendarDateAssignment extends SimpleORMap implements Event return false; } $end = $this->getEnd(); - return ($end->format('Ymd') === $begin->format('Ymd') - && $end->format('His') === '235959'); + return $end->format('His') === '235959'; } public function isWritable(string $user_id): bool -- GitLab