diff --git a/lib/ice_cube/parsers/ical_parser.rb b/lib/ice_cube/parsers/ical_parser.rb index 1de093ad..22800376 100644 --- a/lib/ice_cube/parsers/ical_parser.rb +++ b/lib/ice_cube/parsers/ical_parser.rb @@ -5,7 +5,7 @@ def self.schedule_from_ical(ical_string, options = {}) ical_string.each_line do |line| (property, value) = line.split(":") (property, tzid) = property.split(";") - zone = Time.find_zone(tzid) if tzid.present? + zone = find_zone(tzid) if tzid.present? case property when "DTSTART" value = { time: value, zone: zone } if zone.present? @@ -92,5 +92,21 @@ def self.rule_from_ical(ical) Rule.from_hash(params) end + + private + + def self.find_zone(tzid) + (_, zone) = tzid&.split("=") + begin + Time.find_zone!(zone) if zone.present? + rescue ArgumentError + (rails_zone, tzinfo_id) = ActiveSupport::TimeZone::MAPPING.find do |(k, _)| + candidate = Time.find_zone!(k) + candidate.now.strftime("%Z") == zone + end + + Time.find_zone(rails_zone) + end + end end end