feedback: Consider start and end attributes when reporting task durations

Instead of relying on the modification times, we can use the values of
the start and end attributes, if available.

This allows us to perform historical changes that result in correct
duration intervals reported by task info.

Closes #2514
This commit is contained in:
Tomas Babej 2021-06-26 13:54:27 -04:00
parent a519cf59f2
commit cc0ba46873

View file

@ -171,9 +171,19 @@ std::string taskInfoDifferences (
}
else if (name == "start")
{
Datetime started (before.get ("start"));
Datetime stopped;
if (after.has ("end"))
// Task was marked as finished, use end time
stopped = Datetime (after.get ("end"));
else
// Start attribute was removed, use modification time
stopped = Datetime (current_timestamp);
out << format ("{1} deleted (duration: {2}).",
Lexer::ucFirst (name),
Duration (current_timestamp - last_timestamp).format ())
Duration (stopped - started).format ())
<< "\n";
}
else