entry.GetDuration() fix for negative duration total with ongoing task; ref #11

This commit is contained in:
Derek Stevens 2021-06-13 22:21:50 -06:00
parent 5e52fbd243
commit 0f742c4a50
No known key found for this signature in database
GPG key ID: 3B7FBC22144E6398

View file

@ -131,6 +131,9 @@ func (entry *Entry) GetOutputForTrack(isRunning bool, wasRunning bool) (string)
func (entry *Entry) GetDuration() (decimal.Decimal) {
duration := entry.Finish.Sub(entry.Begin)
if (duration < 0) {
duration = time.Now().Sub(entry.Begin)
}
return decimal.NewFromFloat(duration.Hours())
}