diff --git a/ChangeLog b/ChangeLog index c91e2779c..6bf96b6f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ represents a feature release, and the Z represents a patch. + Added averages to the "task history" report + Added ability to override ~/.taskrc with rc: + Added bar chart history report "task ghistory" + + Supports relative due: dates (tomorrow, wednesday, 23rd, eom ...) + Bug: Fixed where Esc[0m sequences were being emitted for no good reason + Bug: Fixed underlined table headers when color is turned off diff --git a/html/task.html b/html/task.html index fdac75d58..096fce4fa 100644 --- a/html/task.html +++ b/html/task.html @@ -54,6 +54,8 @@
  • Added bar chart history report "task ghistory"
  • Added support for rc:<file> to allow override of the default ~/.taskrc file +
  • Added support for relative due: dates, such as "tomorrow", "friday", + "23rd", "eom"
  • Fixed bug where Esc[0m sequences were being emitted for no good reason
  • Fixed bug where table headers are underlined when color is turned off diff --git a/src/Date.cpp b/src/Date.cpp index d386fb081..0ac8ea7ab 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -508,6 +508,7 @@ time_t Date::operator- (const Date& rhs) bool Date::isRelativeDate (const std::string& input) { std::string in (lowerCase (input)); + Date today; std::vector supported; supported.push_back ("monday"); @@ -528,7 +529,6 @@ bool Date::isRelativeDate (const std::string& input) if (autoComplete (in, supported, matches) == 1) { std::string found = matches[0]; - Date today; // If day name. int dow; @@ -575,7 +575,64 @@ bool Date::isRelativeDate (const std::string& input) mT = then.mT; return true; } -// \d|\d\d|\d\d\d|\d\d\d\d st|nd|rd|th + } + + // Support "21st" to indicate the next date that is the 21st day. + else if (input.length () <= 4 && + isdigit (input[0])) + { + int number; + std::string ordinal; + + if (isdigit (input[1])) + { + number = ::atoi (input.substr (0, 2).c_str ()); + ordinal = lowerCase (input.substr (2, std::string::npos)); + } + else + { + number = ::atoi (input.substr (0, 2).c_str ()); + ordinal = lowerCase (input.substr (1, std::string::npos)); + } + + // Sanity check. + if (number <= 31) + { + if (ordinal == "st" || + ordinal == "nd" || + ordinal == "rd" || + ordinal == "th") + { + int m = today.month (); + int d = today.day (); + int y = today.year (); + + // If it is this month. + if (d < number && + number <= Date::daysInMonth (m, y)) + { + Date then (m, number, y); + mT = then.mT; + return true; + } + + do + { + m++; + + if (m > 12) + { + m = 1; + y++; + } + } + while (number > Date::daysInMonth (m, y)); + + Date then (m, number, y); + mT = then.mT; + return true; + } + } } return false; diff --git a/src/tests/date.t.cpp b/src/tests/date.t.cpp index a28c2d6d5..623d089b5 100644 --- a/src/tests/date.t.cpp +++ b/src/tests/date.t.cpp @@ -211,7 +211,8 @@ int main (int argc, char** argv) catch (std::string& e) { - std::cout << e << std::endl; + fail ("Exception thrown."); + diag (e); } return 0;