obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.33k stars 221 forks source link

Recurrence '🔁 every 4 weeks on Sunday when done' recurs as '1st Sunday after completion date', if the reference date is not Sunday #609

Open claremacrae opened 2 years ago

claremacrae commented 2 years ago

Expected Behavior

The following line is recognised by the edit Task dialog as having a recurring pattern of '🔁 every 4 weeks on Sunday when done', as expected from the text.

- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-04-10

When I mark it as complete on Tuesday 19th April, I expect it to be re-scheduled for the 4th Sunday after Tuesday 19th April which is Sunday 15th May

Expected behaviour when completed on Tuesday 19th April:
- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-05-15
- [x] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-04-10 ✅ 2022-04-19

Current Behavior

- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-04-10

However, when I mark it as complete on Tuesday 19th April, the result is:

Actual behaviour when completed on Tuesday 19th April
- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-04-24
- [x] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-04-10 ✅ 2022-04-19

That is, it seems to have picked the next Sunday, rather than the 4th Sunday.

Steps to Reproduce

  1. Create this task
- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday when done 📅 2022-04-10
  1. Mark it is complete

  2. Make sure that the completion date of the new task is at least 4 weeks away.

Context (Environment)

Possible Solution

None yet, but here's some more research...

Other observations


This one works:

- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday 📅 2022-04-10

... becoming the 4th Sunday after the previous due date...

- [ ] Export Cloud Outlook data 🔁 every 4 weeks on Sunday 📅 2022-05-08
- [x] Export Cloud Outlook data 🔁 every 4 weeks on Sunday 📅 2022-04-10 ✅ 2022-04-19

As does this:

- [ ] Export Cloud Outlook data 🔁 every 4 weeks when done 📅 2022-04-10

becoming 4 weeks after it was marked as complete...

- [ ] Export Cloud Outlook data 🔁 every 4 weeks when done 📅 2022-05-17
- [x] Export Cloud Outlook data 🔁 every 4 weeks when done 📅 2022-04-10 ✅ 2022-04-19
schemar commented 2 years ago

Trying it at https://jakubroztocil.github.io/rrule/, it could be the case that rrule is ignoring dtstart? If I set it manually (see second screenshot), it works as expected. Maybe we need to better set dtstart within our code? :thinking:

image image

claremacrae commented 2 years ago

Thanks!

Trying it at https://jakubroztocil.github.io/rrule/

When I first read your reply on my phone, I was all "cool, we should document that site...". Having seen the screenshots and tried it out, I'm not so sure. I think the learning curve is probably too high for it to be useful to users...

Maybe we need to better set dtstart within our code?

I don't (yet) understand that, but it does sound intriguing. Will do some reading about rrule at some point.

schemar commented 2 years ago

To be honest, I assume it's a bug in the rrule implementation where we cannot do anything about it, but I still have a tiny bit of hope :sweat_smile:

AnnaKornfeldSimpson commented 2 years ago

Repro'd the issue starting this thread on current stable Obsidian and tasks. I then explored the tasks in the developer console and found the following:

claremacrae commented 6 months ago

I've just had another example of this.

- [x] Download bank statements 🔁 every 3 months on the last Friday ⏳ 2022-04-29 ✅ 2022-04-29 
- [x] Download bank statements 🔁 every 3 months on the last Friday ⏳ 2022-08-12 ✅ 2022-08-06 
- [x] Download bank statements 🔁 every 3 months on the last Friday ⏳ 2022-11-25 ✅ 2022-11-16 
- [x] Download bank statements 🔁 every 3 months on the last Friday ⏳ 2023-02-24 ✅ 2023-06-24 
- [x] Download bank statements 🔁 every 3 months on the last Friday ⏳ 2023-05-26 ✅ 2023-06-24 
- [x] Download bank statements 🔁 every 3 months on the last Friday when done ⏳ 2023-08-25 ✅ 2024-02-11 
- [ ] Download bank statements 🔁 every 3 months on the last Friday when done ⏳ 2024-02-23

Note how before I added when done the every 3 months bit was working.

But once I added when done, it's now picked the last Friday in this month.

claremacrae commented 2 months ago

I've been experimenting with writing some tests - and the pattern looks like: