mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
2 new report columns
- countdown and countdown_compact
This commit is contained in:
parent
e80769794e
commit
883e264319
4 changed files with 60 additions and 3 deletions
|
@ -409,6 +409,56 @@ int runCustomReport (
|
|||
dueColumn = columnCount;
|
||||
}
|
||||
|
||||
else if (*col == "countdown")
|
||||
{
|
||||
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Countdown");
|
||||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
std::string due;
|
||||
std::string countdown;
|
||||
Date now;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
due = tasks[row].get ("due");
|
||||
if (due.length ())
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
time_t cntdwn = (time_t) (now - dt);
|
||||
countdown = formatSeconds ( cntdwn < 0 ? cntdwn * -1 : cntdwn );
|
||||
if ( cntdwn < 0 )
|
||||
countdown = std::string("- ") + countdown;
|
||||
context.hooks.trigger ("format-countdown", "countdown", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (*col == "countdown_compact")
|
||||
{
|
||||
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Countdown");
|
||||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
std::string due;
|
||||
std::string countdown;
|
||||
Date now;
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
due = tasks[row].get ("due");
|
||||
if (due.length ())
|
||||
{
|
||||
Date dt (::atoi (due.c_str ()));
|
||||
time_t cntdwn = (time_t) (now - dt);
|
||||
countdown = formatSecondsCompact ( cntdwn < 0 ? cntdwn * -1 : cntdwn );
|
||||
if ( cntdwn < 0 )
|
||||
countdown = std::string("- ") + countdown;
|
||||
context.hooks.trigger ("format-countdown_compact", "countdown_compact", countdown);
|
||||
table.addCell (row, columnCount, countdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (*col == "age")
|
||||
{
|
||||
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Age");
|
||||
|
@ -700,6 +750,8 @@ void validReportColumns (const std::vector <std::string>& columns)
|
|||
*it != "end" &&
|
||||
*it != "end_time" &&
|
||||
*it != "due" &&
|
||||
*it != "countdown" &&
|
||||
*it != "countdown_compact" &&
|
||||
*it != "age" &&
|
||||
*it != "age_compact" &&
|
||||
*it != "active" &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue