Created
September 6, 2009 03:02
-
-
Save byingyang/181626 to your computer and use it in GitHub Desktop.
Script to batch import tasks into the "Things" app by Cultured Code
This file contains hidden or 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
# format: | |
# -------------- | |
# date (mm/dd/yy) | |
# assignment | |
# assignment | |
# ... | |
# | |
# date | |
# assignment | |
# ... | |
require 'rubygems' | |
require 'appscript' | |
require 'date' | |
class Date | |
def to_gm_time | |
to_time(new_offset, :gm) | |
end | |
def to_local_time | |
to_time(new_offset(DateTime.now.offset - offset + 1), :local) | |
end | |
private | |
def to_time(dest, method) | |
#Convert a fraction of a day to a number of microseconds | |
usec = (dest.sec_fraction * 60 * 60 * 24 * (10**6)).to_i | |
Time.send(method, dest.year, dest.month, dest.day, dest.hour, dest.min, | |
dest.sec, usec) | |
end | |
end | |
area = ARGV[0] | |
file = ARGV[1] | |
get_date = true | |
date = nil | |
File.open(file).readlines.each do |line| | |
if line != "\n" | |
if get_date | |
date = DateTime.parse(line.chomp).to_local_time | |
get_date = false | |
else | |
Appscript.app('Things').areas[area].make(:new => :to_do, :with_properties => {:name => line.chomp, :due_date => date}) | |
end | |
else | |
get_date = true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've updated this to work with Things 2.2 as of October 14, 2013 in my fork:
https://gist.github.com/jverkoey/6983934