From cc0ba46873ba979721a6be7be86938c0aa80e022 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 26 Jun 2021 13:54:27 -0400 Subject: [PATCH] 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 --- src/feedback.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/feedback.cpp b/src/feedback.cpp index 7cb567ddf..a2133a9a8 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -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