From 3077c50774c1a3c6e3ed0c2c9623561d494d0c90 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Jun 2008 15:44:26 -0400 Subject: [PATCH] - "calendar" command now uses oldest and newest due dates for limits. --- src/task.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/task.cpp b/src/task.cpp index aae937af5..c1e71753f 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -1876,38 +1876,43 @@ void handleReportCalendar (const TDB& tdb, T& task, Config& conf) // Find the oldest pending due date. Date oldest; + Date newest; std::vector ::iterator it; for (it = pending.begin (); it != pending.end (); ++it) { if (it->getAttribute ("due") != "") { Date d (::atoi (it->getAttribute ("due").c_str ())); - if (d < oldest) - oldest = d; + + if (d < oldest) oldest = d; + if (d > newest) newest = d; } } - // Iterate from oldest due month, year to now. + // Iterate from oldest due month, year to newest month, year. Date today; - int m = oldest.month (); - int y = oldest.year (); + int mFrom = oldest.month (); + int yFrom = oldest.year (); + + int mTo = newest.month (); + int yTo = newest.year (); std::cout << std::endl; std::string output; - while (y < today.year () || (y == today.year () && m <= today.month ())) + while (yFrom < yTo || (yFrom == yTo && mFrom <= mTo)) { - std::cout << Date::monthName (m) + std::cout << Date::monthName (mFrom) << " " - << y + << yFrom << std::endl << std::endl - << renderMonth (m, y, today, pending, conf) + << renderMonth (mFrom, yFrom, today, pending, conf) << std::endl; - if (++m == 13) + if (++mFrom == 13) { - m = 1; - ++y; + mFrom = 1; + ++yFrom; } } }