Skip to content
Snippets Groups Projects
Commit 1f2d0c1e authored by Arnaud Levy's avatar Arnaud Levy
Browse files

simpler

parent 5110e211
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,7 @@ class Communication::Website::Agenda::Event < ApplicationRecord
title: "#{title} #{subtitle}",
url: url,
description: summary,
all_day: (from_hour.nil? && to_hour.nil?)
all_day: all_day?
)
end
......@@ -172,15 +172,25 @@ class Communication::Website::Agenda::Event < ApplicationRecord
end
def to_time
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
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)
end
end
def all_day?
from_hour.nil? && to_hour.nil?
end
def date_and_time(date, time)
Time.new(date.year, date.month, date.day, time.hour, time.min, time.sec, time.zone)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment