samg / timetrap

Simple command line timetracker
http://rubygems.org/gems/timetrap
Other
1.49k stars 116 forks source link

Configure option for forced rounding UP #46

Closed npostulart closed 1 year ago

npostulart commented 12 years ago

Is it possible to tell timetrap on round to always rounding up?

I sometimes have very small time entries and want to round it up to 5 minutes duration. I configured timetrap to round on 300 seconds but on small entries i inly get 0:00:00.

samg commented 12 years ago

There's currently no way to do this, per say, but I can think of a few options to get the behavior you want.

The first is to write a custom formatter (details in README) that manipulates the duration, or prints a billable duration. You could then use that formatter to output a "billable hours" report, or something similar.

The second option would involve adding this functionality to the timetrap core. The current round functionality doesn't actually round the duration. Instead it rounds the start and end times. For example if the round duration is set to 15 minutes every entry will start or end on the hour, a quarter past, half past, etc. This worked out to be the easiest way to get some reasonable rounding behavior and avoid goofy cases where entries overlap, or the cronology doesn't make sense.

I could imagine adding a minimum_rounded_duration or some similar configuration option that forced rounded entries to be at least a minimum length (e.g. 5 minutes). The issue you run into is that events can begin to overlap when rounded, which can beg questions like "How were you able to work 30 minutes in a 5 minute period". I don't think this is a deal breaker, but it does require some thought as to what the "right" behavior is.

A third option would be to allow configuration of a round_strategy or similar. For example you could configure timetrap to always round up, always round down, or round closest. This does get into the complexities of overlapping entries, and choosing start and end times based on a desired duration. It's possible that it could be implemented in a sane way though.

I'd be interested in your feedback on these possibilities. Also happy to provide some help with a custom formatter if you'd like to try that out.

Cheers

kristian-94 commented 2 years ago

I would have use for this functionality too. I want to be able to round a 5 minute phone call up to 15min for the purposes of billing. 1hr5min should be rounded to 1hr15min as well. If I worked on this in a PR to timetrap core would you consider adding it?

samg commented 2 years ago

@kristian-94 - Yes I would definitely consider adding this. I think this could also be achieved using a custom formatter (see https://github.com/samg/timetrap_formatters) which might be an easier path.