Specific Day Reference in TaskPaper

I an using Drafts 5 for my TaskPaper automation for monthly meetings. I would like to send a meeting agenda request 10 business days before the meeting. Using @defer(DATE-10d) can fall on a weekend, I would like it to default to Friday in these cases. How would I do this?


OmniFocus (currently) doesn’t have a way to do this, but if you’re using Drafts then you have the power of JavaScript at your disposal. The way I’d do this is create a script action that looks something like this (warning: untested code):

// about a day.  This has bugs with DST, leap seconds, etc, but good enough
var dayish = 24 * 60 * 60 * 1000;

// ten days ago is?
var date = new Date((new Date()).getTime() - 10 * dayish);

// move back a day while we're on a sat or sunday
while (date.getDay() < 1 || date.getDay() > 5) {
   date = new Date(date.getTime() - dayish);

// set the "tendaysago" tag to something like '2019-01-02' which OF can parse
// don't include the hours / minutes / seconds - start at midnight
draft.setTemplateTag("tendaysago", date.toISOString().split('T')[0]);

Then I’d use the template as you’re doing currently but use @defer([[tendaysago]]) to insert the output of the JavaScript action in the right place


Thanks! I will try it out.