Skip to content

Commit 98dd10c

Browse files
committed
add durations to activity ls
1 parent 7422765 commit 98dd10c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cmd/ls.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ var activityCmd = &cobra.Command{
5858
today, _ := cmd.Flags().GetBool("today")
5959
for _, activity := range activities {
6060
if !today || activity.Date == time.Now().Format("2006-01-02") {
61-
fmt.Printf("%d\t%s\n", activity.Id, activity.Description)
61+
prefix := " "
62+
duration := time.Duration(activity.Seconds * 1000000000)
63+
if activity.TimerStartedAt != "" {
64+
prefix = "*"
65+
started, _ := time.Parse("2006-01-02T15:04:05Z", activity.TimerStartedAt)
66+
elapsed := time.Since(started).Round(time.Second)
67+
duration += elapsed
68+
}
69+
fmt.Printf("%s%d\t%s\t(%s)\n", prefix, activity.Id, activity.Description, duration.String())
6270
}
6371
}
6472
},

0 commit comments

Comments
 (0)