From c2de5bac42b16ed32631073979ea6a98a20ee827 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Fri, 29 Dec 2023 10:45:14 +0100
Subject: [PATCH] Fix #1519

---
 app/models/communication/website/agenda/event/with_cal.rb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/models/communication/website/agenda/event/with_cal.rb b/app/models/communication/website/agenda/event/with_cal.rb
index 5eccee7fc..f92a9cea2 100644
--- a/app/models/communication/website/agenda/event/with_cal.rb
+++ b/app/models/communication/website/agenda/event/with_cal.rb
@@ -36,8 +36,12 @@ module Communication::Website::Agenda::Event::WithCal
   end
 
   def cal_to_time_with_end_day
-    to_hour.nil?  ? date_and_time(to_day, from_hour + 1.hour) # Jour de fin seul, on ajoute 1 heure pour éviter les événements sans durée
-                  : date_and_time(to_day, to_hour) # Jour et heure de fin
+    # Soit on a 1 heure de fin, et tout est simple
+    cal_end_time = to_hour 
+    # Soit on n'en a pas, mais on a 1 heure de début, donc on ajoute 1 heure pour éviter les événements sans durée
+    cal_end_time = from_hour + 1.hour if from_hour
+    cal_end_time.nil? ? to_day.to_time # Il n'y a ni heure de fin ni heure de début
+                      : date_and_time(to_day, cal_end_time) # Il y a bien une heure de fin
   end
 
   def timezone
-- 
GitLab