Skip to content

Instantly share code, notes, and snippets.

@helmuthauser
Last active March 10, 2017 20:25
Show Gist options
  • Save helmuthauser/6a158775d64ae85caf01 to your computer and use it in GitHub Desktop.
Save helmuthauser/6a158775d64ae85caf01 to your computer and use it in GitHub Desktop.
-- original file downloaded From: http://c-command.com/scripts/omnifocus/defer-to-tomorrow
-- augmented code orginally from Ben Waldie
-- https://gist.github.com/benwaldie/4583391
-- ========================================
-- Script to defer Omnifocus task to
-- a defined date
-- ========================================
-- if you want adapt the script to another date and/or time
-- check function "myDeferDate" at the end of this script
-- see comments there
-- ========================================
-- adapted by Helmut Hauser
-- Nov 17, 2015
-- http://www.worksmartandberemarkable.com
-- ========================================
on run {}
repeat with _action in my selectedActions()
my processAction(_action)
end repeat
tell application "OmniFocus"
tell default document
compact
end tell
end tell
end run
on selectedActions()
tell application "OmniFocus"
return my filterValues(my selectedValues(), {inbox task, task, available task, remaining task})
end tell
end selectedActions
on selectedValues()
tell application "OmniFocus"
return value of selected trees of content of first document window of front document
end tell
end selectedValues
on filterValues(_values, _classes)
tell application "OmniFocus"
set _result to {}
repeat with _value in _values
if _classes contains _value's class then
copy _value to end of _result
end if
end repeat
return _result
end tell
end filterValues
on processAction(_action)
tell application "OmniFocus"
set _action's defer date to my calculateDate(_action's defer date)
end tell
end processAction
on calculateDate(_oldDate)
if _oldDate is missing value then
return my myDeferDate()
else
-- return (my midnightTomorrow()) + (time of _oldDate)
return (my myDeferDate())
end if
end calculateDate
# ----------------------------------------
# Here happens the magic. Here we set our desired date
# by setting the variable myDay, myMonth and myYear to our desired date
# For example, desired defer date: Jan. 3, 2016
# set myDay to 3
# set myMonth to 1
# set myYear to 2016
# ----------------------------------------
on myDeferDate()
# ----------------------------------------
# make here your changes
# ----------------------------------------
set myDay to 30
set myMonth to 12 # month as numerical value: January = 1, February = 2, ..., Decemeber = 12
set myYear to 2015
# ----------------------------------------
set _date to current date # we start with the current day
# now we change the date to the desired date
set day of _date to myDay
set month of _date to myMonth
set year of _date to myYear
return _date
end myDeferDate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment