Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kylestratis/f3e8b2858d7120659d619737fb52ad88 to your computer and use it in GitHub Desktop.
Save kylestratis/f3e8b2858d7120659d619737fb52ad88 to your computer and use it in GitHub Desktop.
A fork of TfTHacker's daily tasks query that, among other things, bases dates for overdue/due/upcoming tasks on the current page's title
```dataviewjs
// find dates based on format [[YYYY-MM-DD]]
const findDated = (task)=>{
if( !task.completed && !task.path.startsWith('Bins/Roam Import')) { // ignores Roam imports
task.link = " " + "[[" + task.path + "|*]]";
task.date="";
const found = task.text.match(/\[\[([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\]\]/);
if(found) task.date = moment(found[1]);
return true;
}
}
const myTasks = dv.pages("").file.tasks.where(t => findDated(t));
// filters base comparison dates on daily notes page title, rather than relative day.
dv.header(1,"Overdue");
dv.table(["task","link"], myTasks.filter(t=> moment(t.date).isBefore(dv.current().file.name,"day")).sort(t=>t.date).map(t=>[t.text, t.link]));
dv.header(1,"Today");
dv.table(["task","link"], myTasks.filter(t=> moment(t.date).isSame(dv.current().file.name,"day")).sort(t=>t.date).map(t=>[t.text, t.link]));
dv.header(1,"Upcoming");
dv.table(["task","link"], myTasks.filter(t=> moment(t.date).isAfter(dv.current().file.name,"day")).sort(t=>t.date).map(t=>[t.text, t.link]));
/*
dv.header(1,"Undated");
dv.table(["task","link"], myTasks.filter(t=> !t.date).sort(t=>t.text).map(t=>[t.text, t.link]));
*/
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment