我正在解析一个突然退出解析美国/丹佛时区的feed饲料,其他时区也有效。我正在使用ztinfo gem和最新的rical gem。这是一个显示失败的示例。
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)
components = 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)
答案 0 :(得分:0)
似乎问题是当ical feed中没有STANDARD组件时,只是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