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:
@@ -1479,18 +1479,21 @@ std::string renderMonths (
|
|||||||
today.year () == years.at (mpl))
|
today.year () == years.at (mpl))
|
||||||
table.setCellFg (row, thisCol, Text::cyan);
|
table.setCellFg (row, thisCol, Text::cyan);
|
||||||
|
|
||||||
std::vector <Task>::iterator it;
|
foreach (task, all)
|
||||||
for (it = all.begin (); it != all.end (); ++it)
|
|
||||||
{
|
{
|
||||||
Date due (::atoi (it->get ("due").c_str ()));
|
if (task->getStatus () == Task::pending &&
|
||||||
|
task->has ("due"))
|
||||||
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);
|
Date due (::atoi (task->get ("due").c_str ()));
|
||||||
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
|
|
||||||
|
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;
|
Date newest;
|
||||||
foreach (task, tasks)
|
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 < oldest) oldest = d;
|
||||||
if (d > newest) newest = d;
|
if (d > newest) newest = d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,12 +101,10 @@ std::string formatSeconds (time_t delta)
|
|||||||
sprintf (formatted, "%d wk%s", // TODO i18n
|
sprintf (formatted, "%d wk%s", // TODO i18n
|
||||||
(int) (days / 7.0),
|
(int) (days / 7.0),
|
||||||
((int) (days / 7.0) == 1 ? "" : "s")); // TODO i18n
|
((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
|
sprintf (formatted, "%d day%s", // TODO i18n
|
||||||
(int) days,
|
(int) days,
|
||||||
((int) days == 1 ? "" : "s")); // TODO i18n
|
((int) days == 1 ? "" : "s")); // TODO i18n
|
||||||
else if (days > 1.0)
|
|
||||||
sprintf (formatted, "%.1f days", days); // TODO i18n
|
|
||||||
else if (days * 24 > 1.0)
|
else if (days * 24 > 1.0)
|
||||||
sprintf (formatted, "%d hr%s", // TODO i18n
|
sprintf (formatted, "%d hr%s", // TODO i18n
|
||||||
(int) (days * 24.0),
|
(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
|
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 > 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 > 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, "%dd", (int) days); // TODO i18n
|
||||||
else if (days > 1.0) sprintf (formatted, "%.1fd", days); // TODO i18n
|
|
||||||
else if (days * 24 > 1.0) sprintf (formatted, "%dh", (int) (days * 24.0)); // 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 * 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
|
else if (days * 24 * 3600 > 1) sprintf (formatted, "%ds", (int) (days * 24 * 60 * 60)); // TODO i18n
|
||||||
|
|||||||
Reference in New Issue
Block a user