summaryrefslogtreecommitdiff
path: root/dulatx.md
blob: e73149d067afc80157b7294963e68ea8215e4adf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
id: dulatx
date: 2026-02-28T12:37:24+0300
languages: [en]
aliases:

reviews:

tags:
- draft
- invention
- snippet

- taskwarrior
---
# Fix for recurrent tasks in Taskwarrior

I made this patch to fix the issue of `until` and `scheduled` being not recalculated:
```diff
diff --git a/src/recur.cpp b/src/recur.cpp
index 482fc1060..251acb58c 100644
--- a/src/recur.cpp
+++ b/src/recur.cpp
@@ -118,6 +118,30 @@ void handleRecurrence() {
             rec.setStatus(Task::pending);
           }
 
+          if (t.has("scheduled")) {
+            Datetime old_scheduled(t.get_date("scheduled"));
+            Datetime old_due(t.get_date("due"));
+            Datetime due(d);
+            auto scheduled = checked_add_datetime(due, old_scheduled - old_due);
+            if (scheduled) {
+              rec.set("scheduled", format(scheduled->toEpoch()));
+            } else {
+              rec.remove("scheduled");
+            }
+          }
+
+          if (t.has("until")) {
+            Datetime old_until(t.get_date("until"));
+            Datetime old_due(t.get_date("due"));
+            Datetime due(d);
+            auto until = checked_add_datetime(due, old_until - old_due);
+            if (until) {
+              rec.set("until", format(until->toEpoch()));
+            } else {
+              rec.remove("until");
+            }
+          }
+
           rec.set("imask", i);
           rec.remove("mask");  // Remove the mask of the parent.
 
@@ -157,7 +181,11 @@ bool generateDueDates(Task& parent, std::vector<Datetime>& allDue) {
   Datetime until;
   if (parent.get("until") != "") {
     until = Datetime(parent.get("until"));
-    specificEnd = true;
+
+    // NOTE: this disables note generation from recur when reached `until`
+    // This is not what behaviour I want, so I disable this.
+    //
+    // specificEnd = true;
   }
 
   auto recurrence_limit = Context::getContext().config.getInteger("recurrence.limit");
```

## Up
- 

## Related
- [Recurrent tasks в TaskWarrior](cmyx2d)