Display duration of each activity session

This commit is contained in:
Justin Forest 2012-12-17 17:09:16 +04:00 committed by Paul Beckingham
parent 745d24e124
commit c0fbfcc58c
4 changed files with 15 additions and 4 deletions

View file

@ -35,6 +35,7 @@
#include <stdlib.h>
#include <inttypes.h>
#include <Context.h>
#include <Duration.h>
#include <main.h>
#include <text.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
// 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))
<< "\n";
}
else if (*name == "start") {
out << format (STRING_FEEDBACK_ATT_DEL_DUR, ucFirst (*name),
Duration(current_timestamp - last_timestamp).formatPrecise())
<< "\n";
}
else
{
out << format (STRING_FEEDBACK_ATT_DEL, ucFirst (*name))
@ -230,10 +236,14 @@ std::string taskInfoDifferences (const Task& before, const Task& after, const st
<< "\n";
}
else
{
if (*name == "start")
last_timestamp = current_timestamp;
out << format (STRING_FEEDBACK_ATT_WAS_SET,
ucFirst (*name),
renderAttribute (*name, after.get (*name), dateformat))
<< "\n";
}
}
for (name = beforeAtts.begin (); name != beforeAtts.end (); ++name)