From dcd613622ec454e368fc6e1d6596a40439fac51b Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 18 Dec 2021 21:41:20 -0700 Subject: [PATCH] add missing case in entry and fix unit formatting; ref #13 --- z/entry.go | 10 +++++----- z/statsCmd.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/z/entry.go b/z/entry.go index 92a7eea..af4a0c7 100644 --- a/z/entry.go +++ b/z/entry.go @@ -107,13 +107,13 @@ func (entry *Entry) GetOutputForTrack(isRunning bool, wasRunning bool) (string) now := time.Now() trackDiffNow := now.Sub(entry.Begin) - trackDiffNowOut := time.Time{}.Add(trackDiffNow) + durationString := fmtDuration(trackDiffNow) if isRunning == true && wasRunning == false { outputPrefix = "began tracking" } else if isRunning == true && wasRunning == true { outputPrefix = "tracking" - outputSuffix = fmt.Sprintf(" for %sh", color.FgLightWhite.Render(trackDiffNowOut.Format("15:04"))) + outputSuffix = fmt.Sprintf(" for %sh", color.FgLightWhite.Render(durationString)) } else if isRunning == false && wasRunning == false { outputPrefix = "tracked" } @@ -143,7 +143,7 @@ func (entry *Entry) GetOutputForFinish() (string) { trackDiff := entry.Finish.Sub(entry.Begin) taskDuration := fmtDuration(trackDiff) - outputSuffix = fmt.Sprintf(" for %s h", color.FgLightWhite.Render(taskDuration)) + outputSuffix = fmt.Sprintf(" for %sh", color.FgLightWhite.Render(taskDuration)) if entry.Task != "" && entry.Project != "" { return fmt.Sprintf("%s finished tracking %s on %s%s\n", CharFinish, color.FgLightWhite.Render(entry.Task), color.FgLightWhite.Render(entry.Project), outputSuffix) @@ -172,7 +172,7 @@ func (entry *Entry) GetOutput(full bool) (string) { taskDuration := fmtDuration(trackDiff) if full == false { - output = fmt.Sprintf("%s %s on %s from %s to %s (%s h) %s", + output = fmt.Sprintf("%s %s on %s from %s to %s (%sh) %s", color.FgGray.Render(entry.ID), color.FgLightWhite.Render(entry.Task), color.FgLightWhite.Render(entry.Project), @@ -182,7 +182,7 @@ func (entry *Entry) GetOutput(full bool) (string) { color.FgLightYellow.Render(isRunning), ) } else { - output = fmt.Sprintf("%s\n %s on %s\n %s h from %s to %s %s\n\n Notes:\n %s\n", + output = fmt.Sprintf("%s\n %s on %s\n %sh from %s to %s %s\n\n Notes:\n %s\n", color.FgGray.Render(entry.ID), color.FgLightWhite.Render(entry.Task), color.FgLightWhite.Render(entry.Project), diff --git a/z/statsCmd.go b/z/statsCmd.go index a91ecb3..ba4c3df 100644 --- a/z/statsCmd.go +++ b/z/statsCmd.go @@ -51,7 +51,7 @@ var statsCmd = &cobra.Command{ func init() { rootCmd.AddCommand(statsCmd) - statsCmd.Flags().BoolVar(&fractional, "decimal", false, "Show fractional hours in decimal format instead of minutes") + statsCmd.Flags().BoolVar(&fractional, "decimal", false, "Show fractional hours in decimal format instead of minutes") var err error database, err = InitDatabase() if err != nil {