Posts

Showing posts with the label ical

ICAL - specifications

hi, here is the ical specifications listed by wiki.. http://upload.wikimedia.org/wikipedia/en/c/c0/ICalendarSpecification.png Thanks.

ICAL-RSS convertion using vpim gem

hi, i have done the same rss to ical ,vise-versa using vpim gem.. here is the gem home.. http://vpim.rubyforge.org/ This is my code.. require 'rubygems' require 'vpim/icalendar' require'feed_tools' require'digest/md5' feed = FeedTools::Feed.open("http://rss.cnn.com/rss/edition_world.rss") cal = Vpim::Icalendar.create2 feed.items.each do |item| cal.add_event do |e| e.dtstart item.time e.dtend item.time e.summary item.title.to_s e.description item.description.to_s e.url item.link e.uid Digest::MD5.hexdigest("#{item.title} #{item.link}") e.access_class "PUBLIC" e.transparency 'OPAQUE' now = Time.now e.created now e.lastmod now e.organizer do |o| o.cn = "Example Organizer, Mr." o.uri = "mailto:organizer@example.com" end end end icsfile = cal.encode f=File.open('2.ics','w') f.write(icsfile) put...

Ical to Rss Converter

hi, first execute the rss to ical converter, store it in a file, then use this script, to convert it into rss. require 'rubygems' require 'net/http' require 'uri' require 'time' class Time def self.gcalschema(tzid) # We may not be handling Time Zones in the best way... tzid =~ /(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)Z/ ? # yyyymmddThhmmss Time.xmlschema("#{$1}-#{$2}-#{$3}T#{$4}:#{$5}:#{$6}") : nil end end class ICal attr_accessor :hash, :raw def initialize(ical_data) self.raw = ical_data self.hash = self.parse_ical_data(self.raw) end def parse_ical_data(data) data.gsub!(/\\\n/, "\\n") data.gsub!(/[\n\r]+ /, "\\n") lines = data.split(/[\n\r]+/) structure = [{}] keys_path = [] last_is_array = false lines.each do |line| line.gsub!(/\\n/, "\n") pair = line.split(':') name = pair.shift ...

RSS to Ical Converter

hi, this program gets the rss feed using the feed_tools gem. then converts into ical. then i ve written it in a file. hope it will be useful. require'rubygems' require'feed_tools' require'digest/md5' require 'icalendar' require 'date' feed = FeedTools::Feed.open("http://timesofindia.indiatimes.com/rssfeeds/-2128932452.cms") cal = Icalendar::Calendar.new cal.custom_property("METHOD","PUBLISH") feed.items.each do |item| event = Icalendar::Event.new event.url=item.link event.uid=Digest::MD5.hexdigest("#{item.title} #{item.link}") event.dtstart = item.time.strftime("%Y%m%dT%H%M%S") event.dtend = item.time.strftime("%Y%m%dT%H%M%S") event.summary = item.title.to_s event.description = item.description.to_s event.klass = "PUBLIC" cal.add_event(event) end ical= cal.to_ical f=File.open("rss2ical.ics","w") f.write(ical) puts ical.to_html