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

fix

parent 635cef61
No related branches found
No related tags found
No related merge requests found
......@@ -3,37 +3,41 @@ module Communication::Website::Agenda::Event::WithCal
def cal
@cal ||= AddToCalendar::URLs.new(
start_datetime: from_time,
end_datetime: to_time,
start_datetime: cal_from_time,
end_datetime: cal_to_time,
timezone: timezone.name,
all_day: cal_all_day,
title: "#{title} #{subtitle}",
url: url,
description: summary,
all_day: (from_hour.nil? && to_hour.nil?)
description: summary
)
end
protected
def from_time
def cal_from_time
from_hour.nil? ? from_day.to_time
: date_and_time(from_day, from_hour)
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 sans jour 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
def cal_to_time
to_day.nil? ? cal_to_time_with_no_end_day
: cal_to_time_with_end_day
end
def cal_all_day
from_hour.nil? && to_hour.nil?
end
# Ce cas n'est plus possible depuis la résolution #1386
def cal_to_time_with_no_end_day
to_hour.nil? ? nil # Pas de fin
: date_and_time(from_day, to_hour) # Heure de fin sans jour de fin, donc on se base sur le jour de début
end
def cal_to_time_with_end_day
to_hour.nil? ? to_day.to_time + 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
end
def timezone
......
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