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