mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Merge branch '1.8.0' of git@github.com:pbeckingham/task into 1.8.0
This commit is contained in:
commit
d6168ff6a6
1 changed files with 77 additions and 20 deletions
|
@ -1436,36 +1436,93 @@ 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 ();
|
||||||
|
|
||||||
// Find the oldest pending due date.
|
Date today;
|
||||||
Date oldest;
|
bool getpendingdate = false;
|
||||||
Date newest;
|
int monthsToDisplay;
|
||||||
foreach (task, tasks)
|
int mFrom;
|
||||||
{
|
int yFrom;
|
||||||
if (task->getStatus () == Task::pending)
|
int mTo;
|
||||||
{
|
int yTo;
|
||||||
if (task->has ("due"))
|
|
||||||
{
|
|
||||||
Date d (::atoi (task->get ("due").c_str ()));
|
|
||||||
|
|
||||||
if (d < oldest) oldest = d;
|
// Determine what to do
|
||||||
if (d > newest) newest = d;
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate from oldest due month, year to newest month, year.
|
if (getpendingdate == true) {
|
||||||
Date today;
|
// Find the oldest pending due date.
|
||||||
int mFrom = oldest.month ();
|
Date oldest (1,19,2038);
|
||||||
int yFrom = oldest.year ();
|
foreach (task, tasks)
|
||||||
|
{
|
||||||
|
if (task->getStatus () == Task::pending)
|
||||||
|
{
|
||||||
|
if (task->has ("due"))
|
||||||
|
{
|
||||||
|
Date d (::atoi (task->get ("due").c_str ()));
|
||||||
|
if (d < oldest) oldest = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mFrom = oldest.month();
|
||||||
|
yFrom = oldest.year();
|
||||||
|
}
|
||||||
|
|
||||||
int mTo = newest.month ();
|
mTo = mFrom + monthsToDisplay - 1;
|
||||||
int yTo = newest.year ();
|
yTo = yFrom;
|
||||||
|
if (mTo > 12) {
|
||||||
|
mTo -=12;
|
||||||
|
yTo++;
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue