Skip to content

Instantly share code, notes, and snippets.

@boozook
Forked from Jayphen/New reminder from Launchbar
Created February 28, 2014 18:53
Show Gist options
  • Save boozook/9277303 to your computer and use it in GitHub Desktop.
Save boozook/9277303 to your computer and use it in GitHub Desktop.
on handle_string(str)
set arrayWithDate to my theSplit(str, "@")
if arrayWithDate's length > 1 then
set theDate to my parseDate(getArrayValue(arrayWithDate, 2))
end if
set arrayWithBody to my theSplit(getArrayValue(arrayWithDate, 1), "#")
if arrayWithBody's length > 1 then
set reminderBody to my getArrayValue(arrayWithBody, 2)
else
set reminderBody to ""
end if
set reminderName to getArrayValue(arrayWithBody, 1)
tell application "Reminders"
set listName to list "Inbox"
try
set newReminder to make new reminder with properties {name:reminderName, container:listName, body:reminderBody, remind me date:theDate}
on error
set newReminder to make new reminder with properties {name:reminderName, container:listName, body:reminderBody}
end try
end tell
end handle_string
on theSplit(theString, theDelim)
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelim
set theArray to every text item of theString
set AppleScript's text item delimiters to oldDelimiters
return theArray
end theSplit
on getArrayValue(array, location)
return item location in array
end getArrayValue
on parseDate(theDate)
set date_string to theDate
set date_elements to every word of date_string
set the_date to current date
set {time of the_date, day of the_date} to {0, 1}
set month of the_date to (item 2 of date_elements) as integer
try
set day of the_date to (item 1 of date_elements) as integer
set year of the_date to (item 3 of date_elements) as integer
set time of the_date to (item 4 of date_elements) * 3600
set time of the_date to (time of the_date) + (item 5 of date_elements) * 60
set time of the_date to (time of the_date) + (item 6 of date_elements)
end try
the_date
end parseDate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment