tasktimer icon indicating copy to clipboard operation
tasktimer copied to clipboard

[Feature] Resume timer on existing task

Open tomek-szczesny opened this issue 3 years ago • 6 comments

Hi! I was looking for a similar tool just now and this one is by far the best I could find. I love it! However, I'd love to be able to do breaks in my tasks, and pause the timer for that duration.

I thought that perhaps the easiest way to do it is to let the user resume the timer on a given task. Under the hood, I think one more field in json file, like "break_time" (0 by default) could keep track of seconds that should be subtracted from total elapsed time of a given task. What do you think?

tomek-szczesny avatar Jun 08 '22 12:06 tomek-szczesny

Hi, a resume timer feature would be highly appreciated! My suggestion on how to implement this would be the following:

[
  {
    "desc": "something else",
    "workTimes": [
      {
        "start": time1,
        "end": time2
      },
      {
        "start": time1,
        "end": time2
      },
      {
        "start": time1,
        "end": time2
      }
    ]
  }
]

I would be down to try and implement this if you think this is a valid approach

maxRN avatar Jan 16 '23 17:01 maxRN

The approach that I suggested would not break backward compatibility, with only one field added (that may safely default to 0 if not present). Otherwise one would have to implement format conversion as well, so the user files won't become useless after update.

tomek-szczesny avatar Jan 16 '23 18:01 tomek-szczesny

feel free to take a swing at it, yes

caarlos0 avatar Jan 16 '23 18:01 caarlos0

The approach that I suggested would not break backward compatibility, with only one field added (that may safely default to 0 if not present).

Otherwise one would have to implement format conversion as well, so the user files won't become useless after update.

Ah, of course you're right I totally missed that!

I'm having a little trouble understanding your proposed solution, though: If I understand correctly: when we resume a task we take the delta between the current time and the end time and add this duration (in seconds) to the breakTime. And when we pause the task again we just update the end time and the new total is now the delta between end and start time, minus the breakTime in seconds?

maxRN avatar Jan 16 '23 18:01 maxRN

That is exactly what I had in mind. Sounds even better after you explained it back to me. :)

tomek-szczesny avatar Jan 16 '23 18:01 tomek-szczesny

Resurrecting the thread, if anyone is interested in pursuing it a little further - there's a working version with task restarter here https://github.com/caarlos0/tasktimer/pull/127

[!CAUTION] Will work only on new projects, I haven't tested it with any old ones. As it changed the base structure of entities. Some exporters may not work either, but the report I use works fine.

jugglingjsons avatar Dec 27 '23 18:12 jugglingjsons