diff --git a/src/commands/CmdBurndown.cpp b/src/commands/CmdBurndown.cpp index d1500fd68..2247a9df7 100644 --- a/src/commands/CmdBurndown.cpp +++ b/src/commands/CmdBurndown.cpp @@ -927,6 +927,7 @@ int CmdBurndownMonthly::execute (std::string& output) int rc = 0; // Scan the pending tasks, applying any filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -962,6 +963,7 @@ int CmdBurndownWeekly::execute (std::string& output) int rc = 0; // Scan the pending tasks, applying any filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -997,6 +999,7 @@ int CmdBurndownDaily::execute (std::string& output) int rc = 0; // Scan the pending tasks, applying any filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index f3b221c57..27b1f1479 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -73,6 +73,7 @@ int CmdCalendar::execute (std::string& output) monthsPerLine = preferredMonthsPerLine; // Load the pending tasks. + handleUntil (); handleRecurrence (); auto tasks = context.tdb2.pending.get_tasks (); diff --git a/src/commands/CmdCount.cpp b/src/commands/CmdCount.cpp index 005f735fd..df4d63b15 100644 --- a/src/commands/CmdCount.cpp +++ b/src/commands/CmdCount.cpp @@ -51,6 +51,7 @@ CmdCount::CmdCount () int CmdCount::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index ffe789a20..31d8a5ad5 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -91,6 +91,7 @@ int CmdCustom::execute (std::string& output) context.cli2.addFilter (reportFilter); // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 748844ebd..2b309e0ac 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -72,6 +72,7 @@ CmdEdit::CmdEdit () int CmdEdit::execute (std::string&) { // Filter the tasks. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdExport.cpp b/src/commands/CmdExport.cpp index 4dbb2641d..f42429e20 100644 --- a/src/commands/CmdExport.cpp +++ b/src/commands/CmdExport.cpp @@ -55,6 +55,7 @@ int CmdExport::execute (std::string& output) int rc = 0; // Make sure reccurent tasks are generated. + handleUntil (); handleRecurrence (); // Apply filter. diff --git a/src/commands/CmdHistory.cpp b/src/commands/CmdHistory.cpp index 455cad6a6..0c7d25faf 100644 --- a/src/commands/CmdHistory.cpp +++ b/src/commands/CmdHistory.cpp @@ -335,6 +335,7 @@ int CmdHistoryBase::execute (std::string& output) completedGroup.clear (); // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdIDs.cpp b/src/commands/CmdIDs.cpp index f9c134a20..13c08bd50 100644 --- a/src/commands/CmdIDs.cpp +++ b/src/commands/CmdIDs.cpp @@ -58,6 +58,7 @@ CmdIDs::CmdIDs () int CmdIDs::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -151,6 +152,7 @@ CmdCompletionIds::CmdCompletionIds () int CmdCompletionIds::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -189,6 +191,7 @@ CmdZshCompletionIds::CmdZshCompletionIds () int CmdZshCompletionIds::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -229,6 +232,7 @@ CmdUUIDs::CmdUUIDs () int CmdUUIDs::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -265,6 +269,7 @@ CmdCompletionUuids::CmdCompletionUuids () int CmdCompletionUuids::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; @@ -301,6 +306,7 @@ CmdZshCompletionUuids::CmdZshCompletionUuids () int CmdZshCompletionUuids::execute (std::string& output) { // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdProjects.cpp b/src/commands/CmdProjects.cpp index 344ae6c6c..6ba648a1c 100644 --- a/src/commands/CmdProjects.cpp +++ b/src/commands/CmdProjects.cpp @@ -60,6 +60,7 @@ int CmdProjects::execute (std::string& output) int rc = 0; // Get all the tasks. + handleUntil (); handleRecurrence (); auto tasks = context.tdb2.pending.get_tasks (); @@ -178,6 +179,7 @@ CmdCompletionProjects::CmdCompletionProjects () int CmdCompletionProjects::execute (std::string& output) { // Get all the tasks. + handleUntil (); handleRecurrence (); auto tasks = context.tdb2.pending.get_tasks (); diff --git a/src/commands/CmdSummary.cpp b/src/commands/CmdSummary.cpp index 617813b3f..d106a3268 100644 --- a/src/commands/CmdSummary.cpp +++ b/src/commands/CmdSummary.cpp @@ -66,6 +66,7 @@ int CmdSummary::execute (std::string& output) bool showAllProjects = context.config.getBoolean ("summary.all.projects"); // Apply filter. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index 3ef082e13..0537589d9 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -81,6 +81,7 @@ int CmdTimesheet::execute (std::string& output) } // Apply filter to get a set of tasks. + handleUntil (); handleRecurrence (); Filter filter; std::vector filtered; diff --git a/src/main.h b/src/main.h index 8625fcf6f..39a04cd7e 100644 --- a/src/main.h +++ b/src/main.h @@ -44,6 +44,7 @@ void updateRecurrenceMask (Task&); // recur2.cpp void handleRecurrence2 (); +void handleUntil (); // nag.cpp bool nag (Task&); diff --git a/src/recur.cpp b/src/recur.cpp index 7eec836e5..38805b6bb 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -139,18 +139,6 @@ void handleRecurrence () context.footnote (format (STRING_RECUR_CREATE, t.get ("description"))); } } - - // Non-recurring tasks expire too. - else - { - if (t.has ("until") && - Datetime (t.get_date ("until")) < now) - { - t.setStatus (Task::deleted); - context.tdb2.modify(t); - context.footnote (onExpiration (t)); - } - } } } diff --git a/src/recur2.cpp b/src/recur2.cpp index 2f030ded9..498d719bc 100644 --- a/src/recur2.cpp +++ b/src/recur2.cpp @@ -27,6 +27,7 @@ #include #include #include +#include extern Context context; @@ -82,3 +83,22 @@ void handleRecurrence2 () } //////////////////////////////////////////////////////////////////////////////// +// Delete expired tasks. +void handleUntil () +{ + Datetime now; + auto tasks = context.tdb2.pending.get_tasks (); + for (auto& t : tasks) + { + if (t.getStatus () == Task::pending && + t.has ("until") && + Datetime (t.get_date ("until")) < now) + { + t.setStatus (Task::deleted); + context.tdb2.modify(t); + context.footnote (onExpiration (t)); + } + } +} + +////////////////////////////////////////////////////////////////////////////////