mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
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:
parent
a4f9493ce7
commit
62449d8b3e
2 changed files with 22 additions and 19 deletions
|
@ -1479,10 +1479,12 @@ 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"))
|
||||||
|
{
|
||||||
|
Date due (::atoi (task->get ("due").c_str ()));
|
||||||
|
|
||||||
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
|
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
|
||||||
due.day () == d &&
|
due.day () == d &&
|
||||||
|
@ -1493,6 +1495,7 @@ std::string renderMonths (
|
||||||
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
|
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for end of week, and...
|
// Check for end of week, and...
|
||||||
int eow = 6;
|
int eow = 6;
|
||||||
|
@ -1531,6 +1534,8 @@ std::string handleReportCalendar ()
|
||||||
Date oldest;
|
Date oldest;
|
||||||
Date newest;
|
Date newest;
|
||||||
foreach (task, tasks)
|
foreach (task, tasks)
|
||||||
|
{
|
||||||
|
if (task->getStatus () == Task::pending)
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
|
@ -1540,6 +1545,7 @@ std::string handleReportCalendar ()
|
||||||
if (d > newest) newest = d;
|
if (d > newest) newest = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate from oldest due month, year to newest month, year.
|
// Iterate from oldest due month, year to newest month, year.
|
||||||
Date today;
|
Date today;
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue