mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
New functionality for "task cal"
- 'task cal' or 'task cal y' Prints a calendar starting from the current month/year - 'task cal due' or 'task cal due y' Prints a calendar starting from the month with the oldest active due task - 'task cal 2010' Prints a yearly 12-month calendar - 'task cal 4 2010' or 'task cal 4 2010 y' Prints a calendar starting from the given month/year Calendars are either printed as 12 month calendars (y) or printed with the number of months that fits into the terminal width
This commit is contained in:
parent
8bcf459a52
commit
f3659cf709
1 changed files with 15 additions and 29 deletions
|
@ -1436,9 +1436,10 @@ 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 ();
|
||||||
|
|
||||||
|
@ -1455,7 +1456,6 @@ std::string handleReportCalendar ()
|
||||||
|
|
||||||
if (numberOfArgs == 1 ) {
|
if (numberOfArgs == 1 ) {
|
||||||
// task cal
|
// task cal
|
||||||
printf("Case 1\n");
|
|
||||||
monthsToDisplay = monthsPerLine;
|
monthsToDisplay = monthsPerLine;
|
||||||
mFrom = today.month();
|
mFrom = today.month();
|
||||||
yFrom = today.year();
|
yFrom = today.year();
|
||||||
|
@ -1463,20 +1463,17 @@ std::string handleReportCalendar ()
|
||||||
else if (numberOfArgs == 2 ) {
|
else if (numberOfArgs == 2 ) {
|
||||||
if (context.args[1] == "y") {
|
if (context.args[1] == "y") {
|
||||||
// task cal y
|
// task cal y
|
||||||
printf("Case 2\n");
|
|
||||||
monthsToDisplay = 12;
|
monthsToDisplay = 12;
|
||||||
mFrom = today.month();
|
mFrom = today.month();
|
||||||
yFrom = today.year();
|
yFrom = today.year();
|
||||||
}
|
}
|
||||||
else if (context.args[1] == "due") {
|
else if (context.args[1] == "due") {
|
||||||
// task cal due
|
// task cal due
|
||||||
printf("Case 3\n");
|
|
||||||
monthsToDisplay = monthsPerLine;
|
monthsToDisplay = monthsPerLine;
|
||||||
getpendingdate = true;
|
getpendingdate = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// task cal 2010
|
// task cal 2010
|
||||||
printf("Case 5\n");
|
|
||||||
monthsToDisplay = 12;
|
monthsToDisplay = 12;
|
||||||
mFrom = 1;
|
mFrom = 1;
|
||||||
yFrom = ::atoi( context.args[1].data());
|
yFrom = ::atoi( context.args[1].data());
|
||||||
|
@ -1485,13 +1482,11 @@ std::string handleReportCalendar ()
|
||||||
else if (numberOfArgs == 3 ) {
|
else if (numberOfArgs == 3 ) {
|
||||||
if (context.args[2] == "y") {
|
if (context.args[2] == "y") {
|
||||||
// task cal due y
|
// task cal due y
|
||||||
printf("Case 4\n");
|
|
||||||
monthsToDisplay = 12;
|
monthsToDisplay = 12;
|
||||||
getpendingdate = true;
|
getpendingdate = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// task cal 8 2010
|
// task cal 8 2010
|
||||||
printf("Case 6\n");
|
|
||||||
monthsToDisplay = monthsPerLine;
|
monthsToDisplay = monthsPerLine;
|
||||||
mFrom = ::atoi( context.args[1].data());
|
mFrom = ::atoi( context.args[1].data());
|
||||||
yFrom = ::atoi( context.args[2].data());
|
yFrom = ::atoi( context.args[2].data());
|
||||||
|
@ -1499,28 +1494,25 @@ std::string handleReportCalendar ()
|
||||||
}
|
}
|
||||||
else if (numberOfArgs == 4 ) {
|
else if (numberOfArgs == 4 ) {
|
||||||
// task cal 8 2010 y
|
// task cal 8 2010 y
|
||||||
printf("Case 7\n");
|
monthsToDisplay = 12;
|
||||||
monthsToDisplay = 12;
|
mFrom = ::atoi( context.args[1].data());
|
||||||
mFrom = ::atoi( context.args[1].data());
|
yFrom = ::atoi( context.args[2].data());
|
||||||
yFrom = ::atoi( context.args[2].data());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the oldest pending due date.
|
if (getpendingdate == true) {
|
||||||
Date oldest;
|
// Find the oldest pending due date.
|
||||||
printf("Number of tasks %i\n",tasks.size());
|
Date oldest (1,19,2038);
|
||||||
foreach (task, tasks)
|
foreach (task, tasks)
|
||||||
{
|
|
||||||
printf("ID %i\n",task->id);
|
|
||||||
if (task->getStatus () == Task::pending)
|
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->getStatus () == Task::pending)
|
||||||
{
|
{
|
||||||
Date d (::atoi (task->get ("due").c_str ()));
|
if (task->has ("due"))
|
||||||
if (d < oldest) oldest = d;
|
{
|
||||||
|
Date d (::atoi (task->get ("due").c_str ()));
|
||||||
|
if (d < oldest) oldest = d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (getpendingdate == true) {
|
|
||||||
mFrom = oldest.month();
|
mFrom = oldest.month();
|
||||||
yFrom = oldest.year();
|
yFrom = oldest.year();
|
||||||
}
|
}
|
||||||
|
@ -1532,12 +1524,6 @@ std::string handleReportCalendar ()
|
||||||
yTo++;
|
yTo++;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
std::stringstream out;
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
std::string output;
|
std::string output;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue