Created
July 11, 2018 15:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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