I hate to admit it :-) but I’m not succeeding in getting a task’s Due Date bumped by eg 2 days. The recipes for bumping a javascript Date object by 2 days - as found on the web - give bizarre results.
Would someone mind posting a fragment for bumping a task’s due date by, say, 2 days? And I can take it from there. It’s literally, given a task object in a working plug in, bumping its Due Date. (I’ve got the plug in code otherwise working.)
Sure. Paste this code inside a text file with .omnifocusjs extension. I should this code only show the plug-in available if every task in the selection has a due date.
/*{
"type": "action",
"author": "unlocked2412",
"version": "0.1",
"description": "Bump a task's due date by 2 days"
}*/
(() => Object.assign(
new PlugIn.Action(selection => {
// main :: IO ()
const main = () => {
// addDays :: Int -> Date -> Date
const addDays = n => dte => {
const dte2 = new Date(dte);
return (
dte2.setDate(n + dte.getDate()),
dte2
);
};
const
ts = selection
.tasks
.filter(task => null !== task.dueDate);
return ts.map(task => {
const
taskDate = task.dueDate;
return (
task.dueDate = addDays(2)(taskDate),
task
)
})
};
// MAIN -----------------------------------------
return main()
}), {
validate: selection =>
selection
.tasks
.filter(task => null !== task.dueDate)
.length > 0
}
))();
And then the plug-in seemed to fall off the share sheet on iOS when I tried to drag it too far up the share sheet - in edit mode. Strange. The plug-in is still installed and still working - on Mac, iPhone, and iPad. It also is in the toolbar on Mac.
I should probably copy the code into a new plug-in .omnifocusjs file and see what happens.
I mean do you know how this works in Things? It’s built in, I press Command-S and then I get a window like this where I can also type in free form numbers, days, deltas, whatever.
After seeing this, I switched back to Things and couldn’t be happier.