From 5110e21105c63a23f402e6c962822cb855782998 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Wed, 27 Dec 2023 18:23:59 +0100
Subject: [PATCH] refactor

---
 .../communication/website/agenda/event.rb      | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb
index 0a352ab59..912fb496b 100644
--- a/app/models/communication/website/agenda/event.rb
+++ b/app/models/communication/website/agenda/event.rb
@@ -172,18 +172,12 @@ class Communication::Website::Agenda::Event < ApplicationRecord
   end
 
   def to_time
-    if to_day.nil? && to_hour.nil?
-      # Pas de fin
-      nil
-    elsif to_day.nil? && to_hour.present?
-      # Heure de fin, donc on se base sur le jour de début
-      date_and_time(from_day, to_hour)
-    elsif to_day.present? && to_hour.nil?
-      # Jour de fin seul
-      to_day.to_time
-    elsif to_day.present? && to_hour.nil?
-      # Jour et heure de fin
-      date_and_time(to_day, to_hour)
+    if to_day.nil?
+      to_hour.nil?  ? nil # Pas de fin, ni jour ni heure
+                    : date_and_time(from_day, to_hour) # Heure de fin, donc on se base sur le jour de début
+    elsif to_day.present?
+      to_hour.nil?  ? to_day.to_time # Jour de fin seul
+                    : date_and_time(to_day, to_hour) # Jour et heure de fin
     end
   end
 
-- 
GitLab