Skip to content

Commit

Permalink
Merge pull request #7 from foobaragency/6-ls-remove-seconds-from-time…
Browse files Browse the repository at this point in the history
…-display

do a better job formatting elapsed time
  • Loading branch information
prmaloney authored Jan 23, 2024
2 parents 73c7e89 + eaf25d7 commit af2dd13
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ var taskCmd = &cobra.Command{
},
}

func fmtDuration(d time.Duration) string {
d = d.Round(time.Minute)
h := d / time.Hour
d -= h * time.Hour
m := d / time.Minute
return fmt.Sprintf("%02d:%02d", h, m)
}

var activityCmd = &cobra.Command{
Use: "activity",
Short: "List activities",
Expand All @@ -84,7 +92,7 @@ var activityCmd = &cobra.Command{
}
id := fmt.Sprintf("%d", activity.Id)
date := activity.Date
time := duration.String()
time := fmtDuration(duration)
desc := activity.Description
rows = append(rows, []string{id, date, time, desc})
}
Expand Down

0 comments on commit af2dd13

Please sign in to comment.