Skip to content

Instantly share code, notes, and snippets.

@bps
Created November 4, 2014 20:07
Show Gist options
  • Save bps/d81851455b00e6631d8c to your computer and use it in GitHub Desktop.
Save bps/d81851455b00e6631d8c to your computer and use it in GitHub Desktop.
Normalize review dates
// Normalize review dates to the template project's date iff the project's review interval is the same as the template's. This is useful when you e.g. want to review most projects all at once every two weeks.
var template_project_name = 'Miscellaneous';
var ofocus = Application('OmniFocus');
var projects = ofocus.defaultDocument.projects;
var misc = projects.whose({name:template_project_name})[0];
var misc_review_interval = misc.reviewInterval();
var misc_next_review_date = misc.nextReviewDate();
Progress.description = 'Processing projects'
Progress.totalUnitCount = projects().length;
var progress_unit = 0;
projects().forEach(function(proj) {
var proj_review_interval = proj.reviewInterval();
if (proj.status() === 'active' &&
proj_review_interval.unit === misc_review_interval.unit &&
proj_review_interval.steps === misc_review_interval.steps &&
proj_review_interval.fixed === misc_review_interval.fixed &&
proj.nextReviewDate().getTime() !== misc_next_review_date.getTime()) {
proj.nextReviewDate = misc_next_review_date;
}
Progress.completedUnitCount = progress_unit++;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment