From 62449d8b3efca5eb4966d3de3410ac8b04cfbfba Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 22 Jun 2009 16:58:44 -0400 Subject: [PATCH] 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. --- src/report.cpp | 34 ++++++++++++++++++++-------------- src/util.cpp | 7 ++----- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/report.cpp b/src/report.cpp index 124caf30e..643719ecf 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -1479,18 +1479,21 @@ std::string renderMonths ( today.year () == years.at (mpl)) table.setCellFg (row, thisCol, Text::cyan); - std::vector ::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; + } } } diff --git a/src/util.cpp b/src/util.cpp index e6af2c775..fdf934ac3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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