Only add a timezone once to an ical
This commit is contained in:
parent
e2f9e707c3
commit
4fb494d393
@ -5,12 +5,15 @@
|
|||||||
cal = Icalendar::Calendar.new
|
cal = Icalendar::Calendar.new
|
||||||
@events.each do |event|
|
@events.each do |event|
|
||||||
tzid = event.region.tzid
|
tzid = event.region.tzid
|
||||||
begin
|
if cal.timezones.none? { |t| tzid == t.tzid }
|
||||||
tz = TZInfo::Timezone.get tzid
|
# Only add this zone once
|
||||||
timezone = tz.ical_timezone event.start_time
|
begin
|
||||||
cal.add_timezone timezone
|
tz = TZInfo::Timezone.get tzid
|
||||||
rescue TZInfo::InvalidTimezoneIdentifier
|
timezone = tz.ical_timezone event.start_time
|
||||||
# No need to add this tz
|
cal.add_timezone timezone
|
||||||
|
rescue TZInfo::InvalidTimezoneIdentifier
|
||||||
|
# No need to add this tz
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
cal.event do |e|
|
cal.event do |e|
|
||||||
|
Loading…
Reference in New Issue
Block a user