I'm looking for a good library to output iCalendar formatted files.
Good time zone support, or (better yet) UTC-only dates is a requirement.
I'm looking for a good library to output iCalendar formatted files.
Good time zone support, or (better yet) UTC-only dates is a requirement.
In my opinion, RiCal is pretty much the only gem that should be used for iCalendar support nowadays. vPim isn't well maintained and lacks timezone or UTC support. iCalendar looked promising until time zone and UTC support became a pain.
RiCal handles UTC timestamps wonderfully and according to the author also handles recurring events better than anything else.
Here's an example of using the DSL to create and print the contents of an ics file:
require 'rubygems'
require 'activesupport'
require 'ri_cal'
cal = RiCal.Calendar do |cal|
cal.event do |event|
event.summary = "Mercury MA-6"
event.description = "First US Manned Spaceflight\n(NASA Code: Mercury 13/Friendship 7)"
event.dtstart = Time.parse("1962-02-20T09:47:39-0500").getutc
event.dtend = Time.parse("1962-02-20T14:43:02-0500").getutc
event.location = "Cape Canaveral"
event.add_attendee "[email protected]"
event.url = "http://nasa.gov"
end
end
puts cal.to_s
# >> BEGIN:VCALENDAR
# >> PRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN
# >> CALSCALE:GREGORIAN
# >> VERSION:2.0
# >> BEGIN:VEVENT
# >> DTEND;VALUE=DATE-TIME:19620220T194302Z
# >> DTSTART;VALUE=DATE-TIME:19620220T144739Z
# >> ATTENDEE:[email protected]
# >> URL:http://nasa.gov
# >> DESCRIPTION:First US Manned Spaceflight\n(NASA Code: Mercury 13/Friendshi
# >> p 7)
# >> SUMMARY:Mercury MA-6
# >> LOCATION:Cape Canaveral
# >> END:VEVENT
# >> END:VCALENDAR