From: Aleks Kissinger Date: 2006-08-17T07:28:11+09:00 Subject: Google Calendar + ruby = timesheets I use Google Calendar to manage my hours and excel to push out timesheets, so I wrote a little ruby script that extacts all the events from a google cal and dumps them to CSV: I thought someone else here might like it. Just go to calendar settings and paste the private "ICAL" link into HOUR_CAL. require 'open-uri' require 'date' HOUR_CAL = ### url goes here events = [] ical = open(HOUR_CAL) ical.each_line do |line| line.chomp! if line =~ /BEGIN:VEVENT/ events << {} elsif line =~ /DT(START|END);TZID=([^:]*):(.*)/ events.last[$1.downcase] = DateTime.parse($3) elsif line =~ /SUMMARY:(.*)/ events.last['task'] = $1 end end ical.close puts %("task","date","in","out","hours") events.each do |e| t = e['task'].gsub('"','') d = e['start'].strftime('%m/%d/%Y') st = e['start'].strftime('%I:%m %p') et = e['end'].strftime('%I:%m %p') diff = (e['end']-e['start'])*24.0 puts %("#{t}","#{d}","#{st}","#{et}","#{diff}"\n) end - aleks