Skip to content

Commit

Permalink
Add fxn to format the break time and output it for the status command
Browse files Browse the repository at this point in the history
  • Loading branch information
rknizzle committed Jun 3, 2021
1 parent 14d605e commit 289529f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cli/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ func statusCommand(t *core.Timetrace) *cobra.Command {
project,
trackedTimeCurrent,
report.FormatTodayTime(),
report.FormatBreakTime(),
},
}
out.Table([]string{"Current project", "Worked since start", "Worked today"}, rows, nil)
out.Table([]string{"Current project", "Worked since start", "Worked today", "Breaks"}, rows, nil)
},
}

Expand Down
6 changes: 6 additions & 0 deletions core/timetrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ func (report *Report) FormatCurrentTime() string {
return formatDuration(*report.TrackedTimeCurrent)
}

// FormatBreakTime returns the formated string of the total time
// taking breaks today following the format convention
func (report *Report) FormatBreakTime() string {
return formatDuration(report.BreakTimeToday)
}

// formatDuration formats the passed duration into a string.
// The format will be "8h 24min". If the duration is less then 60 secods
// the format will be "0h 0min 12sec".
Expand Down

0 comments on commit 289529f

Please sign in to comment.