diff --git a/ChangeLog b/ChangeLog index a30adc1bd..a5769fbbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ Features + TW-261 Easy to create "not deletable" task (thanks to Jan Kunder). + TW-1255 New testing framework (thanks to Renato Alves). + TW-1258 Portuguese Localization (thanks to Renato Alves). + + TW-1260 New virtual tags YESTERDAY, TOMORROW. + Removed deprecated 'echo.command' setting, in favor of the 'header' and 'affected' verbosity tokens. + Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity diff --git a/NEWS b/NEWS index f7da4f5cd..f607c2135 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ New Features in taskwarrior 2.4.0 - Removed deprecated commands 'push', 'pull' and 'merge'. - Portuguese (por-PRT) localization. - Better handling for deletion of recurring tasks. + - New virtual tags: YESTERDAY, TOMORROW. New commands in taskwarrior 2.4.0 diff --git a/doc/man/task.1.in b/doc/man/task.1.in index a01201cd4..192a982c7 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -571,9 +571,11 @@ are: BLOCKED Matches if the task is blocked UNBLOCKED Matches if the task is not blocked BLOCKING Matches if the task is blocking + YESTERDAY Matches if the task was due sometime yesterday DUE Matches if the task is due DUETODAY Matches if the task is due today TODAY Matches if the task is due today + TOMORROW Matches if the task is due sometime tomorrow WEEK Matches if the task is due this week MONTH Matches if the task is due this month YEAR Matches if the task is due this year diff --git a/src/Task.cpp b/src/Task.cpp index a914ea855..85c77344c 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -342,6 +342,24 @@ bool Task::is_due () const return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Task::is_dueyesterday () const +{ + if (has ("due")) + { + Task::status status = getStatus (); + + if (status != Task::completed && + status != Task::deleted) + { + if (Date ("yesterday").sameDay (get_date ("due"))) + return true; + } + } + + return false; +} + //////////////////////////////////////////////////////////////////////////////// bool Task::is_duetoday () const { @@ -360,6 +378,24 @@ bool Task::is_duetoday () const return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Task::is_duetomorrow () const +{ + if (has ("due")) + { + Task::status status = getStatus (); + + if (status != Task::completed && + status != Task::deleted) + { + if (Date ("tomorrow").sameDay (get_date ("due"))) + return true; + } + } + + return false; +} + //////////////////////////////////////////////////////////////////////////////// bool Task::is_dueweek () const { @@ -1081,6 +1117,8 @@ bool Task::hasTag (const std::string& tag) const if (tag == "DUE") return is_due (); if (tag == "DUETODAY") return is_duetoday (); if (tag == "TODAY") return is_duetoday (); + if (tag == "YESTERDAY") return is_dueyesterday (); + if (tag == "TOMORROW") return is_duetomorrow (); if (tag == "OVERDUE") return is_overdue (); if (tag == "WEEK") return is_dueweek (); if (tag == "MONTH") return is_duemonth (); @@ -1094,12 +1132,6 @@ bool Task::hasTag (const std::string& tag) const if (tag == "ANNOTATED") return hasAnnotations (); if (tag == "PARENT") return has ("mask"); -/* - TODO YESTERDAY - due yesterday - TODO TOMORROW - due tomorrow - TODO READY - is ready -*/ - // Concrete tags. std::vector tags; split (tags, get ("tags"), ','); diff --git a/src/Task.h b/src/Task.h index 51d3449ce..a431c4aa3 100644 --- a/src/Task.h +++ b/src/Task.h @@ -104,7 +104,9 @@ public: #ifdef PRODUCT_TASKWARRIOR bool is_due () const; + bool is_dueyesterday () const; bool is_duetoday () const; + bool is_duetomorrow () const; bool is_dueweek () const; bool is_duemonth () const; bool is_dueyear () const;