[Feature Request]: Option to configure segment timestamp (start and end) rounding to a specified period
Description:
While real-time tracking of time is great, in some cases, work needs to be recorded in specific increments (such as 5, 10, 15 minutes).
It would be great to enhance the time tracker to provide a configurable option (on/off (default)) that would round the start and end times for each segment as they are entered / recorded to a specified time increment (5, 10, 15 minutes, etc).
The following prototype illustrates the configuration element - although an additional configuration element would also be needed to allow the rounding increment to be specified.
I note that there may also be a need to optionally (configuration) prevent an entry from having the same start and end times. This could occur if the entry was started and stopped within the configured rounding interval. In this case, if the configuration is enabled, I would suggest adding the configured rounding interval. Something similar to the following (from a config perspective):
Acceptance Criteria:
Segment Timestamp Rounding (off): This is the default mode of operation and preserves the existing behaviour. No change is expected from the current behavior in this mode.
Segment Timestamp Rounding (on): When segment timestamp rounding is enabled, a default rounding interval (i.e. 5 min) should be specified by the system, with an optional configuration allowing the user to alter this (i.e. to 10 minutes, etc).
When a new segment is started, the Start time needs to be rounded to the nearest configured interval. When an existing segment is ended, the End time needs to be rounded to the nearest configured interval.
Note, under this configuration, it is possible for the Start and End times to be rounded to the same time.
Prevent Same Start and End Times (off): When this configuration is disabled (default), start and end times can be the same (when rounded).
Prevent Same Start and End Times (on): When this configuration is enabled, start and end times cannot be the same. If the start and end times are the same once rounded, the end time should be adjusted by an additional rounding increment. that is, assuming a 5min rounding increment, if both start and end time are 11:00, then 5min should be added to the end time to obtain 11:05.
Benefits: For users who require time to be logged in structured incremental blocks, this will make the time tracking system significantly more useful and reduce unproductive time needed to constantly edit each entry.
I have prototyped some rough changes on a fork. I will share these via a pull request.
Hi, thanks so much for your in-depth suggestion and prototype!! I really like the idea, but you're losing me a bit in the specifics.
- I think the start/end time overlap prevention doesn't need a setting at all. If the start time is always rounded down and the end time is always rounded up, there isn't any danger of the start and end time ending up being the same. I think that's the easiest & best solution. Your idea of how the overlap prevention would work also poses a flaw: if the tracking was started at 11:56 and ended at 11:59, the tracker suddenly claims you worked from 12:00 to 12:05, a time increment that didn't even overlap with your actual work time. I also don't like the idea of there being a valid plugin configuration where the start and end time do end up being the same automatically - from my perspective, that's undefined behavior and shouldn't be "encouraged" by the plugin.
- I don't think the rounding setting should be a toggle. In my opinion, it makes more sense for it to just be an input box of "minutes to round to". If the setting is set to 0, no rounding occurs; if the setting is set to 1, all times are rounded to full minutes, and so on.
I haven't checked your pull request yet, but feel free to either update it with my suggestions or leave it as-is - it'll likely still be helpful as a basis for me to work off of when I fully implement this feature :) Also let me know what you think about my perspective of course!!
Thanks for coming back so quickly.
Appreciate the plugin and personally I'm using it daily to track notes about my work time - so wanted to give back in some way.
This is certainly a "scratch my own itch" situation and happy for you to take or leave whatever you want.
I'm not a TypeScript dev but the changes weren't complex so i figured it out the best I could.
I generalised the time rounding function so the rounding is the same for both start and end - which could be what caused occasion for the same start and end time (ie if I worked on something for only 5min but had rounding set to 15min).
Good idea about only requiring the user to set the rounding interval. I will have a shot at improving my prototype and will update the PR if I have something useful.
I have updated the PR with refactoring to remove the rounding toggle and rely solely on a rounding interval being set (>0) or not.