Skip to content

Commit

Permalink
do a better job formatting elapsed time
Browse files Browse the repository at this point in the history
  • Loading branch information
prmaloney committed Jan 23, 2024
1 parent 73c7e89 commit eaf25d7
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 eaf25d7

Please sign in to comment.