Bug 452 - Need relative date value 'now' to fully support times

- Added 'now' as a relative date.
- Modified 'overdue' report to use 'now' instead of 'today' as the
  distinction between due and overdue.
This commit is contained in:
Paul Beckingham 2010-07-30 22:46:07 -04:00
parent 1cf1e79e43
commit d0db821298
5 changed files with 25 additions and 6 deletions

View file

@ -303,7 +303,7 @@ std::string Config::defaults =
"report.overdue.columns=id,project,priority,due,active,age,description\n"
"report.overdue.labels=ID,Project,Pri,Due,Active,Age,Description\n"
"report.overdue.sort=due+,priority-,active-,project+\n"
"report.overdue.filter=status:pending due.before:today\n"
"report.overdue.filter=status:pending due.before:now\n"
"#report.overdue.dateformat=m/d/Y\n"
"#report.overdue.annotations=full\n"
"\n"

View file

@ -868,6 +868,7 @@ bool Date::isEpoch (const std::string& input)
// eow (end of week)
// eom (end of month)
// eoy (end of year)
// now
bool Date::isRelativeDate (const std::string& input)
{
std::string in (lowerCase (input));
@ -901,6 +902,7 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("pentecost");
supported.push_back ("midsommar");
supported.push_back ("midsommarafton");
supported.push_back ("now");
std::vector <std::string> matches;
if (autoComplete (in, supported, matches) == 1)
@ -1052,6 +1054,11 @@ bool Date::isRelativeDate (const std::string& input)
}
}
}
else if (found == "now")
{
mT = time (NULL);
return true;
}
}
// Support "21st" to indicate the next date that is the 21st day.

View file

@ -34,7 +34,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (150);
UnitTest t (154);
try
{
@ -49,6 +49,13 @@ int main (int argc, char** argv)
t.ok (now >= yesterday, "now >= yesterday");
t.ok (now > yesterday, "now > yesterday");
// Date::Date ("now")
Date relative_now ("now");
t.ok (relative_now.sameHour (now), "Date ().sameHour (Date (now))");
t.ok (relative_now.sameDay (now), "Date ().sameDay (Date (now))");
t.ok (relative_now.sameMonth (now), "Date ().sameMonth (Date (now))");
t.ok (relative_now.sameYear (now), "Date ().sameYear (Date (now))");
// Loose comparisons.
Date left ("7/4/2008");
Date comp1 ("7/4/2008");