Skip to content

Commit d0863fe

Browse files
Merge pull request #35 from DylanDevelops/ravel/edit-inconsistencies
fix: Changes are no longer detected when start and end time are left empty in `tmpo edit`
2 parents b849bff + 5221697 commit d0863fe

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

cmd/entries/edit.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"strings"
7+
"time"
78

89
"github.com/DylanDevelops/tmpo/internal/project"
910
"github.com/DylanDevelops/tmpo/internal/storage"
@@ -258,14 +259,20 @@ func EditCmd() *cobra.Command {
258259

259260
hasChanges := false
260261

261-
if !selectedEntry.StartTime.Equal(editedEntry.StartTime) {
262+
selectedStartTrunc := selectedEntry.StartTime.Truncate(time.Minute)
263+
editedStartTrunc := editedEntry.StartTime.Truncate(time.Minute)
264+
265+
if !selectedStartTrunc.Equal(editedStartTrunc) {
262266
hasChanges = true
263267
oldStr := selectedEntry.StartTime.Format("01-02-2006 3:04 PM")
264268
newStr := editedEntry.StartTime.Format("01-02-2006 3:04 PM")
265269
fmt.Printf(" %s %s → %s\n", ui.Bold("Start time:"), ui.Muted(oldStr), newStr)
266270
}
267271

268-
if !selectedEntry.EndTime.Equal(*editedEntry.EndTime) {
272+
selectedEndTrunc := selectedEntry.EndTime.Truncate(time.Minute)
273+
editedEndTrunc := editedEntry.EndTime.Truncate(time.Minute)
274+
275+
if !selectedEndTrunc.Equal(editedEndTrunc) {
269276
hasChanges = true
270277
oldStr := selectedEntry.EndTime.Format("01-02-2006 3:04 PM")
271278
newStr := editedEntry.EndTime.Format("01-02-2006 3:04 PM")

0 commit comments

Comments
 (0)