mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
task cal modifications
This commit is contained in:
parent
ed7a9273d0
commit
b67b64ea00
1 changed files with 80 additions and 9 deletions
|
@ -1530,30 +1530,101 @@ std::string handleReportCalendar ()
|
|||
context.tdb.commit ();
|
||||
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
|
||||
printf("Case 1\n");
|
||||
monthsToDisplay = monthsPerLine;
|
||||
mFrom = today.month();
|
||||
yFrom = today.year();
|
||||
}
|
||||
else if (numberOfArgs == 2 ) {
|
||||
if (context.args[1] == "y") {
|
||||
// task cal y
|
||||
printf("Case 2\n");
|
||||
monthsToDisplay = 12;
|
||||
mFrom = today.month();
|
||||
yFrom = today.year();
|
||||
}
|
||||
else if (context.args[1] == "due") {
|
||||
// task cal due
|
||||
printf("Case 3\n");
|
||||
monthsToDisplay = monthsPerLine;
|
||||
getpendingdate = true;
|
||||
}
|
||||
else {
|
||||
// task cal 2010
|
||||
printf("Case 5\n");
|
||||
monthsToDisplay = 12;
|
||||
mFrom = 1;
|
||||
yFrom = ::atoi( context.args[1].data());
|
||||
}
|
||||
}
|
||||
else if (numberOfArgs == 3 ) {
|
||||
if (context.args[2] == "y") {
|
||||
// task cal due y
|
||||
printf("Case 4\n");
|
||||
monthsToDisplay = 12;
|
||||
getpendingdate = true;
|
||||
}
|
||||
else {
|
||||
// task cal 8 2010
|
||||
printf("Case 6\n");
|
||||
monthsToDisplay = monthsPerLine;
|
||||
mFrom = ::atoi( context.args[1].data());
|
||||
yFrom = ::atoi( context.args[2].data());
|
||||
}
|
||||
}
|
||||
else if (numberOfArgs == 4 ) {
|
||||
// task cal 8 2010 y
|
||||
printf("Case 7\n");
|
||||
monthsToDisplay = 12;
|
||||
mFrom = ::atoi( context.args[1].data());
|
||||
yFrom = ::atoi( context.args[2].data());
|
||||
}
|
||||
|
||||
// Find the oldest pending due date.
|
||||
Date oldest;
|
||||
Date newest;
|
||||
printf("Number of tasks %i\n",tasks.size());
|
||||
foreach (task, tasks)
|
||||
{
|
||||
printf("ID %i\n",task->id);
|
||||
if (task->getStatus () == Task::pending)
|
||||
{
|
||||
if (task->has ("due"))
|
||||
{
|
||||
Date d (::atoi (task->get ("due").c_str ()));
|
||||
|
||||
if (d < oldest) oldest = d;
|
||||
if (d > newest) newest = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getpendingdate == true) {
|
||||
mFrom = oldest.month();
|
||||
yFrom = oldest.year();
|
||||
}
|
||||
|
||||
// Iterate from oldest due month, year to newest month, year.
|
||||
Date today;
|
||||
int mFrom = oldest.month ();
|
||||
int yFrom = oldest.year ();
|
||||
mTo = mFrom + monthsToDisplay - 1;
|
||||
yTo = yFrom;
|
||||
if (mTo > 12) {
|
||||
mTo -=12;
|
||||
yTo++;
|
||||
}
|
||||
|
||||
int mTo = newest.month ();
|
||||
int yTo = newest.year ();
|
||||
printf("monthsToDisplay: %i\n",monthsToDisplay);
|
||||
printf("mFrom: %i\n",mFrom);
|
||||
printf("yFrom: %i\n",yFrom);
|
||||
printf("mTo: %i\n",mTo);
|
||||
printf("yTo: %i\n",yTo);
|
||||
|
||||
std::stringstream out;
|
||||
out << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue