silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

How do tasks with custom states and due dates work?

Open blandir opened this issue 1 year ago • 3 comments

I'm trying to use tasks with custom states and set a due date. However, I cannot figure out what I have to do. I found https://silverbullet.md/Plugs/Tasks but there is no information where to configure the possible task states or how to insert the due date. There is no hint on the SETTINGS page as well.

Could somebody please tell me, where I can find such information?

blandir avatar Mar 13 '24 09:03 blandir

I can't help with custom states, but I'm curious.

For Due Dates: To add a due date to a task, you can either use the attributes syntax or an emoji date format.

  1. Using Attributes Syntax: [due: YYYY-MM-DD]

    - [ ] Submit the final report [due: 2024-03-21]
    

    example queries:

    task where due = "2024-02-29"
    
    task where due <= "2024-02-29"
    
    task where due = null
    
  2. Using Emoji Dates: For a more visual method, include a calendar emoji followed by the date.

    - [ ] Review project milestones 📅 2024-02-29
    

    example queries:

    task where deadline = "2024-02-29"
    
    task where deadline <= "2024-02-29"
    
    task where deadline = null
    

To simplify the writing of due dates, I also created templates for due today, due tomorrow, due next week etc...

Due today template:

---
tags: template
description: "Due today"
hooks.snippet.slashCommand: dueToday
---
[due: {{today}}]

Due next week template

---
tags: template
description: "Due in a week"
hooks.snippet.slashCommand: dueWeek
---
[due: {{dateAdd(today, 7, "days")}}]

this required the creation of a space script to add the dateAdd function:

silverbullet.registerFunction("dateAdd", (baseDate, daysToAdd) => {
  const parsedBaseDate = Temporal.PlainDate.from(baseDate);
  const resultDate = parsedBaseDate.add({ days: daysToAdd });
  return resultDate.toString();
});

simone-viozzi avatar Mar 17 '24 16:03 simone-viozzi