Show if active in time command

This commit is contained in:
Brian Buller 2020-06-01 12:19:54 -05:00
parent ba0e465723
commit fd0b0cfb56

View File

@ -131,16 +131,22 @@ func (a *AppState) opShowTime(args []string) int {
} }
list = list.Filter(doFilters) list = list.Filter(doFilters)
var isActive bool
var total time.Duration var total time.Duration
for _, v := range *list { for _, v := range *list {
dur := v.FinishDate.Sub(v.StartDate) dur := v.FinishDate.Sub(v.StartDate)
if v.FinishDate.IsZero() { if v.FinishDate.IsZero() {
dur = time.Now().Sub(v.StartDate) dur = time.Now().Sub(v.StartDate)
isActive = true
} }
total += dur total += dur
} }
total = total.Round(GetRoundToDuration()) total = total.Round(GetRoundToDuration())
if isActive {
fmt.Printf("%.2f+\n", DurationToDecimal(total))
} else {
fmt.Printf("%.2f\n", DurationToDecimal(total)) fmt.Printf("%.2f\n", DurationToDecimal(total))
}
return 0 return 0
} }