Fixed #2, removed initial check for existing entries, adding a separate one

This commit is contained in:
マリウス 2021-02-07 14:02:32 -04:00
parent ab78ffcd00
commit abc041381e
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F
2 changed files with 6 additions and 1 deletions

View file

@ -47,7 +47,7 @@ func NewEntry(
return Entry{}, err return Entry{}, err
} }
if newEntry.IsFinishedAfterBegan() == false { if id == "" && newEntry.IsFinishedAfterBegan() == false {
return Entry{}, errors.New("beginning time of tracking cannot be after finish time") return Entry{}, errors.New("beginning time of tracking cannot be after finish time")
} }

View file

@ -81,6 +81,11 @@ var finishCmd = &cobra.Command{
} }
} }
if runningEntry.IsFinishedAfterBegan() == false {
fmt.Printf("%s %+v\n", CharError, "beginning time of tracking cannot be after finish time")
os.Exit(1)
}
_, err = database.FinishEntry(user, runningEntry) _, err = database.FinishEntry(user, runningEntry)
if err != nil { if err != nil {
fmt.Printf("%s %+v\n", CharError, err) fmt.Printf("%s %+v\n", CharError, err)