Showing Estimated Duration on iOS (Duration Titles)

Continuing the discussion from Display estimated time duration:

I really wanted to be able see duration on my phone but alas, it’s not built in. So I dreamed up a way to do it this morning.

Below is a script that you can run on the Mac version. It will take the Estimated Duration and append it to the end of the task title: “My awesome task! || 12 mins”

If you rerun the script, it will update or remove the time at the end depending on the edits you’ve made. Also, I’ve added this to my repo of OmniFocus scripts.


var doc = of.defaultDocument;

var today = new Date();
var dueDate = new Date(today.setDate(today.getDate()+7));
var taskList = [];
var flattenedTasks = doc.flattenedTasks.whose({effectivelyCompleted: false, effectivelyDropped: false});

flattenedTasks().forEach(function(task){
  var splitString = task.name().split(" || ");
  var unit = "";
  if (task.estimatedMinutes() !== null) {
    if (task.estimatedMinutes() > 1){
      unit = " || " + task.estimatedMinutes() + " mins";
    } else {
      unit = " || 1 min";
    }
  }
  var newTitle = splitString[0] + unit;
  task.name = newTitle;
});

of.synchronize();
1 Like

Excellent! Thank you!

It might be even better to add the duration estimate to the HEAD of the title. That way, one can sort on time estimates. Still, this is great as-is.

Try this version for that. This is untested so it may need some tweaking.

var doc = of.defaultDocument;

var today = new Date();
var dueDate = new Date(today.setDate(today.getDate()+7));
var taskList = [];
var flattenedTasks = doc.flattenedTasks.whose({effectivelyCompleted: false, effectivelyDropped: false});

flattenedTasks().forEach(function(task){
  var splitString = task.name().split(" || ");
  var unit = "";
  if (task.estimatedMinutes() !== null) {
    if (task.estimatedMinutes() > 1){
      unit = task.estimatedMinutes() + " mins || ";
    } else {
      unit = "1 min || ";
    }
  }
  if (splitString.length > 1) {
    var newTitle = unit + splitString[1];
  }
  else {
    var newTitle = unit + splitString[0];
  }
  task.name = newTitle;
});

of.synchronize();