mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Info report
* added a line to the journal which shows the total time a task was active
This commit is contained in:
parent
8e5ad1288c
commit
792eab8621
1 changed files with 35 additions and 0 deletions
|
@ -708,6 +708,7 @@ int handleInfo (std::string& outs)
|
|||
std::string previous;
|
||||
std::string current;
|
||||
unsigned int i = 0;
|
||||
long time = 0;
|
||||
while (i < undo.size ())
|
||||
{
|
||||
when = undo[i++];
|
||||
|
@ -730,6 +731,20 @@ int handleInfo (std::string& outs)
|
|||
Task before (previous.substr (4));
|
||||
Task after (current.substr (4));
|
||||
journal.addCell (row, 1, taskInfoDifferences (before, after));
|
||||
|
||||
// calculate the total active time
|
||||
if (before.get ("start") == ""
|
||||
&& after.get ("start") != "")
|
||||
{
|
||||
// task started
|
||||
time -= timestamp.toEpoch();
|
||||
}
|
||||
else if (before.get ("start") != ""
|
||||
&& after.get ("start") == "")
|
||||
{
|
||||
// task stopped
|
||||
time += timestamp.toEpoch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -737,6 +752,26 @@ int handleInfo (std::string& outs)
|
|||
if (journal.rowCount () > 0)
|
||||
out << journal.render ()
|
||||
<< "\n";
|
||||
|
||||
// add now() if task is still active
|
||||
if (time < 0)
|
||||
time += Date().toEpoch();
|
||||
|
||||
// print total active time
|
||||
if (time >= 0)
|
||||
{
|
||||
int row = journal.addRow ();
|
||||
int hours = time / 3600;
|
||||
int minutes = (time % 3600) / 60;
|
||||
|
||||
out << "Total active time: "
|
||||
<< hours << "h " << minutes;
|
||||
|
||||
if (minutes == 0)
|
||||
out << "0";
|
||||
|
||||
out << "m\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue