dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
679 stars 75 forks source link

Replace calculations of record durations with new `Duration` method #139

Closed dominikbraun closed 2 years ago

dominikbraun commented 3 years ago

There are at least two places in the code where the duration of a record (e.g. 2h if the record started at 2PM and ended at 4PM) is calculated like so:

record.end.sub(record.start)

Those calculations should be replaced with a new Duration method:

record.Duration()

The implementation of that method would just be something like this:

func (r *Record) Duration() time.Duration {
    return r.end.sub(r.start)
}
alksmt commented 3 years ago

Hey, created a pull request for it including one more use case. Along with usage of record.end.sub(record.start) there were cases for records being tracked at the moment, this method will handle it too now.

dominikbraun commented 2 years ago

Rssolved by #139.