Created
August 29, 2012 07:32
-
-
Save mootoh/3507997 to your computer and use it in GitHub Desktop.
prescript to Automator that extracts the latest Day One journal entry.
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
# | |
# See also: https://gist.github.com/3508021 | |
# | |
require 'rubygems' | |
require 'sqlite3' | |
DAYONE_JOURNAL_PATH = "~/Library/Containers/com.dayoneapp.dayone/Data/Library/Application\ Support/Journal.sqlite" | |
db = SQLite3::Database.new(DAYONE_JOURNAL_PATH) | |
row = db.execute('select Z_PK, Z_ENT, Z_OPT, ZCREATIONYEAR, ZISENTRYDELETED,ZSTARRED,ZCREATIONDATE, ZMODIFIED,ZPHOTOMODIFIED,ZENTRYTEXT, ZUUID, ZLOCATION, ZWEATHER from ZJOURNALENTRY order by Z_PK DESC limit 1')[0] | |
creation_date = DateTime.strptime(row[6].to_s, '%s') | |
creation_date = Time.parse(creation_date.to_s).strftime("%m/%d/%Y %I:%M:%S %p") | |
puts creation_date, row[3], row[9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment