timetrap icon indicating copy to clipboard operation
timetrap copied to clipboard

No error thrown when using --at with a typo

Open marcaddeo opened this issue 9 years ago • 2 comments

For example, if you try to do timetrap in --at "15 minutes aog" it interprets it strangely and you'll end up with 100 hours logged on the entry.

Is there any way to combat this? Or is this just a bug/limitation of the underlying string -> time transformation library?

marcaddeo avatar Mar 16 '16 14:03 marcaddeo

Yeah, it's tricky to implement timetrap in a way to avoid this kind of unexpected behavior while allowing the same level of flexibility in what users can input. (Also a lot is dependent on the underlying behavior of the chronic gem and Time.parse.) There's some discussion of this class of issue at https://github.com/samg/timetrap/issues/10. Basically I've never been able to figure out a clear way to detect these kinds of user errors and avoid passing them into the underlying libraries. If you have suggestions let me know.

samg avatar Mar 16 '16 22:03 samg

Also, for reference, here's where the logic for parsing user provided time strings lives:

https://github.com/samg/timetrap/blob/master/lib/timetrap/timer.rb#L13-L32

samg avatar Mar 16 '16 22:03 samg