From 410efc548d38df9461f7aafc6b8f544f0d664641 Mon Sep 17 00:00:00 2001 From: Mauro Scomparin Date: Fri, 25 Nov 2022 10:41:02 +0100 Subject: [PATCH 1/2] Scheduled attribute updated in handleRecurrence. The "scheduled" attribute of tasks generated by recurring tasks is now updated the same way the "wait" attribute is handled. The difference between the original "scheduled" and "due" dates is added to the "due" date of each generated task when a "scheduled" date is present. --- src/recur.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/recur.cpp b/src/recur.cpp index 482fc1060..5fe6cf742 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -118,6 +118,13 @@ 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); + rec.set("scheduled", format((due + (old_scheduled - old_due)).toEpoch())); + } + rec.set("imask", i); rec.remove("mask"); // Remove the mask of the parent. From d4959136a0e42ec8d3a8d3cf4956935e96379977 Mon Sep 17 00:00:00 2001 From: ashprice Date: Tue, 14 Jul 2026 23:04:34 +0100 Subject: [PATCH 2/2] Added overflow check in scheduled recurrence. Signed-off-by: ashprice --- src/recur.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/recur.cpp b/src/recur.cpp index 5fe6cf742..dc3d957d3 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -122,7 +122,11 @@ void handleRecurrence() { Datetime old_scheduled(t.get_date("scheduled")); Datetime old_due(t.get_date("due")); Datetime due(d); - rec.set("scheduled", format((due + (old_scheduled - old_due)).toEpoch())); + auto scheduled = checked_add_datetime(due, old_scheduled - old_due); + if (scheduled) + rec.set("scheduled", format(scheduled->toEpoch())); + else + rec.remove("scheduled"); } rec.set("imask", i);