RiCal not parsing America/Denver Time zone info
I'm parsing an ical feed which suddenly quit parsing the America/Denver timezone, other timezones work. I'm using the ztinfo gem and latest rical gem. Here's a sample showing the failure.
require 'tzinfo'
require 'ri_cal'
az = <<AZ
BEGIN:VCALENDAR
PRODID:-//SuperSaaS//Super Schedule//EN
METHOD:PUBLISH
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:Fluid Meeting Space
X-WR-TIMEZONE:America/Phoenix
X-WR-RELCALID:40409
BEGIN:VTIMEZONE
TZID:America/Phoenix
BEGIN:STANDARD
TZOFFSETFROM:-0600
TZOFFSETTO:-0700
DTSTART:19671029T010000
RDATE:19671029T010000
TZNAME:MST
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:1641738@supersaas.com
DTSTAMP:20110519T195014Z
DTSTART;TZID=America/Phoenix:20110428T120000
DTEND;TZID=America/Phoenix:20110428T130000
SUMMARY:Dusty
DESCRIPTION:Test Meeting
CREATED:20110428T210637Z
LAST-MODIFIED:20110428T210637Z
URL:http://www.supersaas.com/schedule/red27/Fluid_Meeting_Space?year=2011&m
onth=4&day=28
END:VEVENT
END:VCALENDAR
AZ
mst = <<MST
BEGIN:VCALENDAR
PRODID:-//SuperSaaS//Super Schedule//EN
METHOD:PUBLISH
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:Fluid Meeting Space
X-WR-TIMEZONE:America/Denver
X-WR-RELCALID:40409
BEGIN:VTIMEZONE
TZID:America/Denver
BEGIN:DAYLIGHT
TZOFFSETFROM:-0700
TZOFFSETTO:-0600
DTSTART:20110313T030000
RDATE:20110313T030000
TZNAME:MDT
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:1641738@supersaas.com
DTSTAMP:20110519T192544Z
DTSTART;TZID=America/Denver:20110428T120000
DTEND;TZID=America/Denver:20110428T130000
SUMMARY:Dusty
DESCRIPTION:Test Meeting
CREATED:20110428T210637Z
LAST-MODIFIED:20110428T210637Z
URL:http://www.supersaas.com/schedule/red27/Fluid_Meeting_Space?year=2011&m
onth=4&day=28
END:VEVENT
END:VCALENDAR
MST
def show(vcal)
component开发者_运维百科s = RiCal.parse_string(vcal.strip)
components.each do |cal|
puts cal.events.count
cal.events.each do |e|
puts "UID: #{e.inspect}"
puts "Start: #{e.dtstart} "
puts "End: #{e.dtend} "
puts "******************************"
end
end
end
show(az)
show(mst)
I created a ticket here: http://rick_denatale.lighthouseapp.com/projects/30941-ri_cal/tickets/36-you-have-a-nil-object-when-you-didnt-expect-it-dtstart#ticket-36-3
Seems the issue is when there is not a STANDARD component in the ical feed, just DAYLIGHT.
module RiCal
class Component
class Timezone < Component
def periods_for_local(local)
local = local.to_ri_cal_date_time_value
candidate_standard = last_before_local(standard, local)
candidate_daylight = last_before_local(daylight, local)
if candidate_daylight && candidate_daylight.swallows_local?(local, candidate_standard)
[] # Invalid local time
elsif candidate_standard
if candidate_daylight
if candidate_daylight.dtstart > candidate_standard.dtstart
[candidate_daylight]
elsif candidate_standard.ambiguous_local?(local)
[candidate_daylight, candidate_standard]
else
[candidate_standard].compact
end
else
[candidate_standard].compact
end
elsif candidate_daylight
[candidate_daylight]
end
end
end
end
end
精彩评论