Skip to content

Instantly share code, notes, and snippets.

@whoward
Created July 11, 2018 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoward/fa375b76acb91184c0003b040efcea4d to your computer and use it in GitHub Desktop.
Save whoward/fa375b76acb91184c0003b040efcea4d to your computer and use it in GitHub Desktop.
exports the time tracker data from https://github.com/whoward/time-tracker into ical format
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile "https://rubygems.org" do
gem 'icalendar', '2.4.1'
gem 'sqlite3', '1.3.13'
end
db = SQLite3::Database.new File.join(ENV['HOME'], ".time-tracker.db")
cal = Icalendar::Calendar.new
db.execute("select reason, start, finish from entries").each do |reason, start, finish|
cal.event do |e|
e.summary = reason
e.dtstart = Time.parse(start)
e.dtend = Time.parse(finish)
end
end
File.write(ARGV.first || 'export.ics', cal.to_ical)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment