Merge branch '1.8.0' of git@github.com:pbeckingham/task into 1.8.0

This commit is contained in:
Paul Beckingham 2009-06-25 19:32:48 -04:00
commit d6168ff6a6

View file

@ -1436,15 +1436,72 @@ std::string handleReportCalendar ()
// Get all the tasks. // Get all the tasks.
std::vector <Task> tasks; std::vector <Task> tasks;
Filter filter;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); context.tdb.loadPending (tasks, filter);
context.tdb.commit (); context.tdb.commit ();
context.tdb.unlock (); context.tdb.unlock ();
Date today;
bool getpendingdate = false;
int monthsToDisplay;
int mFrom;
int yFrom;
int mTo;
int yTo;
// Determine what to do
int numberOfArgs = context.args.size();
if (numberOfArgs == 1 ) {
// task cal
monthsToDisplay = monthsPerLine;
mFrom = today.month();
yFrom = today.year();
}
else if (numberOfArgs == 2 ) {
if (context.args[1] == "y") {
// task cal y
monthsToDisplay = 12;
mFrom = today.month();
yFrom = today.year();
}
else if (context.args[1] == "due") {
// task cal due
monthsToDisplay = monthsPerLine;
getpendingdate = true;
}
else {
// task cal 2010
monthsToDisplay = 12;
mFrom = 1;
yFrom = ::atoi( context.args[1].data());
}
}
else if (numberOfArgs == 3 ) {
if (context.args[2] == "y") {
// task cal due y
monthsToDisplay = 12;
getpendingdate = true;
}
else {
// task cal 8 2010
monthsToDisplay = monthsPerLine;
mFrom = ::atoi( context.args[1].data());
yFrom = ::atoi( context.args[2].data());
}
}
else if (numberOfArgs == 4 ) {
// task cal 8 2010 y
monthsToDisplay = 12;
mFrom = ::atoi( context.args[1].data());
yFrom = ::atoi( context.args[2].data());
}
if (getpendingdate == true) {
// Find the oldest pending due date. // Find the oldest pending due date.
Date oldest; Date oldest (1,19,2038);
Date newest;
foreach (task, tasks) foreach (task, tasks)
{ {
if (task->getStatus () == Task::pending) if (task->getStatus () == Task::pending)
@ -1452,20 +1509,20 @@ std::string handleReportCalendar ()
if (task->has ("due")) if (task->has ("due"))
{ {
Date d (::atoi (task->get ("due").c_str ())); Date d (::atoi (task->get ("due").c_str ()));
if (d < oldest) oldest = d; if (d < oldest) oldest = d;
if (d > newest) newest = d;
} }
} }
} }
mFrom = oldest.month();
yFrom = oldest.year();
}
// Iterate from oldest due month, year to newest month, year. mTo = mFrom + monthsToDisplay - 1;
Date today; yTo = yFrom;
int mFrom = oldest.month (); if (mTo > 12) {
int yFrom = oldest.year (); mTo -=12;
yTo++;
int mTo = newest.month (); }
int yTo = newest.year ();
std::stringstream out; std::stringstream out;
out << std::endl; out << std::endl;