diff --git a/ChangeLog b/ChangeLog index d50b46466..6c56cab83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,10 +9,10 @@ Features + Added the new 'indented' format for the 'project' attribute. + The 'projects' report now uses 'project.indented' format. + The 'summary' report now uses 'project.indented' format. - + Introduced a new filter optimization that recognizes filters with no 'OR', or - 'XOR' operators, includes IDs, but does not include UUIDs. This combination - means completed.data is not referenced. - + Sped up task sorting by skipping re-interpretation of certain data types. + + Performance improvements: + + Added parse-free convenience functions + + Filter optimization: with no 'OR' or 'XOR' operators, no UUIDS but with IDs + the completed.data file is not referenced Bugs + Fixed bug #954, which caused bulk deletions when using a UUID filter term and diff --git a/src/Date.cpp b/src/Date.cpp index 75905265d..76d521f72 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -602,43 +602,43 @@ int Date::second () const } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator== (const Date& rhs) +bool Date::operator== (const Date& rhs) const { return rhs._t == _t; } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator!= (const Date& rhs) +bool Date::operator!= (const Date& rhs) const { return rhs._t != _t; } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator< (const Date& rhs) +bool Date::operator< (const Date& rhs) const { return _t < rhs._t; } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator> (const Date& rhs) +bool Date::operator> (const Date& rhs) const { return _t > rhs._t; } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator<= (const Date& rhs) +bool Date::operator<= (const Date& rhs) const { return _t <= rhs._t; } //////////////////////////////////////////////////////////////////////////////// -bool Date::operator>= (const Date& rhs) +bool Date::operator>= (const Date& rhs) const { return _t >= rhs._t; } //////////////////////////////////////////////////////////////////////////////// -bool Date::sameHour (const Date& rhs) +bool Date::sameHour (const Date& rhs) const { if (this->year () == rhs.year () && this->month () == rhs.month () && @@ -650,7 +650,7 @@ bool Date::sameHour (const Date& rhs) } //////////////////////////////////////////////////////////////////////////////// -bool Date::sameDay (const Date& rhs) +bool Date::sameDay (const Date& rhs) const { if (this->year () == rhs.year () && this->month () == rhs.month () && @@ -661,7 +661,7 @@ bool Date::sameDay (const Date& rhs) } //////////////////////////////////////////////////////////////////////////////// -bool Date::sameMonth (const Date& rhs) +bool Date::sameMonth (const Date& rhs) const { if (this->year () == rhs.year () && this->month () == rhs.month ()) @@ -671,7 +671,7 @@ bool Date::sameMonth (const Date& rhs) } //////////////////////////////////////////////////////////////////////////////// -bool Date::sameYear (const Date& rhs) +bool Date::sameYear (const Date& rhs) const { if (this->year () == rhs.year ()) return true; diff --git a/src/Date.h b/src/Date.h index 1ac712cdc..9c80b1028 100644 --- a/src/Date.h +++ b/src/Date.h @@ -85,16 +85,16 @@ public: int minute () const; int second () const; - bool operator== (const Date&); - bool operator!= (const Date&); - bool operator< (const Date&); - bool operator> (const Date&); - bool operator<= (const Date&); - bool operator>= (const Date&); - bool sameHour (const Date&); - bool sameDay (const Date&); - bool sameMonth (const Date&); - bool sameYear (const Date&); + bool operator== (const Date&) const; + bool operator!= (const Date&) const; + bool operator< (const Date&) const; + bool operator> (const Date&) const; + bool operator<= (const Date&) const; + bool operator>= (const Date&) const; + bool sameHour (const Date&) const; + bool sameDay (const Date&) const; + bool sameMonth (const Date&) const; + bool sameYear (const Date&) const; Date operator+ (const int); Date operator- (const int); diff --git a/src/main.h b/src/main.h index f43ad6503..333f37de8 100644 --- a/src/main.h +++ b/src/main.h @@ -47,6 +47,7 @@ Date getNextRecurrence (Date&, std::string&); bool generateDueDates (Task&, std::vector &); void updateRecurrenceMask (Task&); int getDueState (const std::string&); +int getDueState (const Date&); bool nag (Task&); // rules.cpp diff --git a/src/recur.cpp b/src/recur.cpp index c944a38a4..e70c5dbca 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -386,7 +386,7 @@ int getDueState (const std::string& due) Date dt (::atoi (due.c_str ())); // rightNow is the current date + time. - Date rightNow; + static Date rightNow; Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ()); if (dt < rightNow) @@ -408,6 +408,36 @@ int getDueState (const std::string& due) return 0; } +//////////////////////////////////////////////////////////////////////////////// +// Determines whether a task is overdue. Returns +// 0 = not due at all +// 1 = imminent +// 2 = today +// 3 = overdue +int getDueState (const Date& due) +{ + // rightNow is the current date + time. + static Date rightNow; + Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ()); + + if (due < rightNow) + return 3; + + if (rightNow.sameDay (due)) + return 2; + + int imminentperiod = context.config.getInteger ("due"); + + if (imminentperiod == 0) + return 1; + + Date imminentDay = thisDay + imminentperiod * 86400; + if (due < imminentDay) + return 1; + + return 0; +} + //////////////////////////////////////////////////////////////////////////////// // Returns a Boolean indicator as to whether a nag message was generated, so // that commands can control the number of nag messages displayed (ie one is diff --git a/test/count.t b/test/count.t index 2484b6915..6f20f4168 100755 --- a/test/count.t +++ b/test/count.t @@ -45,6 +45,11 @@ qx{../src/task rc:count.rc log two}; qx{../src/task rc:count.rc add three}; qx{../src/task rc:count.rc 2 delete}; qx{../src/task rc:count.rc add four wait:eom}; + +# TODO This fails when today == eom. For example, on 2012-04-30 at 8:00:00, the +# value for 'eom' is 2012-04-30 0:00:00, which is already past due, which +# means a second child task is generated. This would be fixed by 'eom' +# expanding to 2012-04-30 24:00:00, as per ISO-8601. qx{../src/task rc:count.rc add five due:eom recur:monthly}; my $output = qx{../src/task rc:count.rc count};