Bug Fix - Calendar

- Fixed bug in calendar that failed to consider only pending tasks
  when coloring in the calendar display, and when calculating the
  most overdue task to be displayed.
- Modified util.cpp/formatSeconds to stop displaying fractional days,
  because having a task age represented as 5.1 days is silly.
This commit is contained in:
Paul Beckingham 2009-06-22 16:58:44 -04:00
parent a4f9493ce7
commit 62449d8b3e
2 changed files with 22 additions and 19 deletions

View file

@ -1479,18 +1479,21 @@ std::string renderMonths (
today.year () == years.at (mpl))
table.setCellFg (row, thisCol, Text::cyan);
std::vector <Task>::iterator it;
for (it = all.begin (); it != all.end (); ++it)
foreach (task, all)
{
Date due (::atoi (it->get ("due").c_str ()));
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
due.day () == d &&
due.month () == months.at (mpl) &&
due.year () == years.at (mpl))
if (task->getStatus () == Task::pending &&
task->has ("due"))
{
table.setCellFg (row, thisCol, Text::black);
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
Date due (::atoi (task->get ("due").c_str ()));
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
due.day () == d &&
due.month () == months.at (mpl) &&
due.year () == years.at (mpl))
{
table.setCellFg (row, thisCol, Text::black);
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
}
}
}
@ -1532,12 +1535,15 @@ std::string handleReportCalendar ()
Date newest;
foreach (task, tasks)
{
if (task->has ("due"))
if (task->getStatus () == Task::pending)
{
Date d (::atoi (task->get ("due").c_str ()));
if (task->has ("due"))
{
Date d (::atoi (task->get ("due").c_str ()));
if (d < oldest) oldest = d;
if (d > newest) newest = d;
if (d < oldest) oldest = d;
if (d > newest) newest = d;
}
}
}

View file

@ -101,12 +101,10 @@ std::string formatSeconds (time_t delta)
sprintf (formatted, "%d wk%s", // TODO i18n
(int) (days / 7.0),
((int) (days / 7.0) == 1 ? "" : "s")); // TODO i18n
else if (days > 5.0)
else if (days > 1.0)
sprintf (formatted, "%d day%s", // TODO i18n
(int) days,
((int) days == 1 ? "" : "s")); // TODO i18n
else if (days > 1.0)
sprintf (formatted, "%.1f days", days); // TODO i18n
else if (days * 24 > 1.0)
sprintf (formatted, "%d hr%s", // TODO i18n
(int) (days * 24.0),
@ -135,8 +133,7 @@ std::string formatSecondsCompact (time_t delta)
if (days > 365) sprintf (formatted, "%.1fy", (days / 365.2422)); // TODO i18n
else if (days > 84) sprintf (formatted, "%1dmo", (int) (days / 30.6)); // TODO i18n
else if (days > 13) sprintf (formatted, "%dwk", (int) (days / 7.0)); // TODO i18n
else if (days > 5.0) sprintf (formatted, "%dd", (int) days); // TODO i18n
else if (days > 1.0) sprintf (formatted, "%.1fd", days); // TODO i18n
else if (days > 1.0) sprintf (formatted, "%dd", (int) days); // TODO i18n
else if (days * 24 > 1.0) sprintf (formatted, "%dh", (int) (days * 24.0)); // TODO i18n
else if (days * 24 * 60 > 1) sprintf (formatted, "%dm", (int) (days * 24 * 60)); // TODO i18n
else if (days * 24 * 3600 > 1) sprintf (formatted, "%ds", (int) (days * 24 * 60 * 60)); // TODO i18n