mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-27 12:16:21 +02:00
Display duration of each activity session
This commit is contained in:
parent
745d24e124
commit
c0fbfcc58c
4 changed files with 15 additions and 4 deletions
|
@ -381,7 +381,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
std::string previous;
|
std::string previous;
|
||||||
std::string current;
|
std::string current;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
long total_time = 0;
|
long total_time = 0, last_timestamp = 0;
|
||||||
while (i < undo.size ())
|
while (i < undo.size ())
|
||||||
{
|
{
|
||||||
when = undo[i++];
|
when = undo[i++];
|
||||||
|
@ -403,7 +403,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
|
|
||||||
Task before (previous.substr (4));
|
Task before (previous.substr (4));
|
||||||
Task after (current.substr (4));
|
Task after (current.substr (4));
|
||||||
journal.set (row, 1, taskInfoDifferences (before, after, dateformat));
|
journal.set (row, 1, taskInfoDifferences (before, after, dateformat, last_timestamp, timestamp.toEpoch()));
|
||||||
|
|
||||||
// calculate the total active time
|
// calculate the total active time
|
||||||
if (before.get ("start") == ""
|
if (before.get ("start") == ""
|
||||||
|
|
|
@ -713,6 +713,7 @@
|
||||||
#define STRING_FEEDBACK_ATT_SET "{1} will be set to '{2}'."
|
#define STRING_FEEDBACK_ATT_SET "{1} will be set to '{2}'."
|
||||||
#define STRING_FEEDBACK_ATT_MOD "{1} will be changed from '{2}' to '{3}'."
|
#define STRING_FEEDBACK_ATT_MOD "{1} will be changed from '{2}' to '{3}'."
|
||||||
#define STRING_FEEDBACK_ATT_DEL "{1} deleted."
|
#define STRING_FEEDBACK_ATT_DEL "{1} deleted."
|
||||||
|
#define STRING_FEEDBACK_ATT_DEL_DUR "{1} deleted (duration: {2})."
|
||||||
#define STRING_FEEDBACK_ATT_WAS_SET "{1} set to '{2}'."
|
#define STRING_FEEDBACK_ATT_WAS_SET "{1} set to '{2}'."
|
||||||
#define STRING_FEEDBACK_ATT_WAS_MOD "{1} changed from '{2}' to '{3}'."
|
#define STRING_FEEDBACK_ATT_WAS_MOD "{1} changed from '{2}' to '{3}'."
|
||||||
#define STRING_FEEDBACK_ANN_ADD "Annotation of '{1}' added."
|
#define STRING_FEEDBACK_ANN_ADD "Annotation of '{1}' added."
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Duration.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -168,7 +169,7 @@ std::string taskDifferences (const Task& before, const Task& after)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string taskInfoDifferences (const Task& before, const Task& after, const std::string& dateformat)
|
std::string taskInfoDifferences (const Task& before, const Task& after, const std::string& dateformat, long& last_timestamp, const long current_timestamp)
|
||||||
{
|
{
|
||||||
// Attributes are all there is, so figure the different attribute names
|
// Attributes are all there is, so figure the different attribute names
|
||||||
// between before and after.
|
// between before and after.
|
||||||
|
@ -205,6 +206,11 @@ std::string taskInfoDifferences (const Task& before, const Task& after, const st
|
||||||
out << format (STRING_FEEDBACK_ANN_DEL, before.get (*name))
|
out << format (STRING_FEEDBACK_ANN_DEL, before.get (*name))
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
else if (*name == "start") {
|
||||||
|
out << format (STRING_FEEDBACK_ATT_DEL_DUR, ucFirst (*name),
|
||||||
|
Duration(current_timestamp - last_timestamp).formatPrecise())
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << format (STRING_FEEDBACK_ATT_DEL, ucFirst (*name))
|
out << format (STRING_FEEDBACK_ATT_DEL, ucFirst (*name))
|
||||||
|
@ -230,11 +236,15 @@ std::string taskInfoDifferences (const Task& before, const Task& after, const st
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (*name == "start")
|
||||||
|
last_timestamp = current_timestamp;
|
||||||
out << format (STRING_FEEDBACK_ATT_WAS_SET,
|
out << format (STRING_FEEDBACK_ATT_WAS_SET,
|
||||||
ucFirst (*name),
|
ucFirst (*name),
|
||||||
renderAttribute (*name, after.get (*name), dateformat))
|
renderAttribute (*name, after.get (*name), dateformat))
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (name = beforeAtts.begin (); name != beforeAtts.end (); ++name)
|
for (name = beforeAtts.begin (); name != beforeAtts.end (); ++name)
|
||||||
if (*name != "uuid" &&
|
if (*name != "uuid" &&
|
||||||
|
|
|
@ -69,7 +69,7 @@ void dependencyChainOnModify (Task&, Task&);
|
||||||
// feedback.cpp
|
// feedback.cpp
|
||||||
bool taskDiff (const Task&, const Task&);
|
bool taskDiff (const Task&, const Task&);
|
||||||
std::string taskDifferences (const Task&, const Task&);
|
std::string taskDifferences (const Task&, const Task&);
|
||||||
std::string taskInfoDifferences (const Task&, const Task&, const std::string&);
|
std::string taskInfoDifferences (const Task&, const Task&, const std::string&, long&, const long);
|
||||||
std::string renderAttribute (const std::string&, const std::string&, const std::string& format = "");
|
std::string renderAttribute (const std::string&, const std::string&, const std::string& format = "");
|
||||||
void feedback_affected (const std::string&);
|
void feedback_affected (const std::string&);
|
||||||
void feedback_affected (const std::string&, int);
|
void feedback_affected (const std::string&, int);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue