Skip to content

Commit

Permalink
feat: parse all begin/end date formats (#50)
Browse files Browse the repository at this point in the history
Other date formats were already allowed for entries in the ledger data file,
and it was odd to hit time parse errors for dates written in these other
formats with the -b/--begin-date and -e/--end-date flags.
  • Loading branch information
jrick authored Aug 29, 2023
1 parent ffdee7b commit bae70bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ledger/cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/howeyc/ledger"
"github.com/howeyc/ledger/decimal"
date "github.com/joyt/godate"
"github.com/spf13/cobra"
)

Expand All @@ -34,8 +35,8 @@ func cliTransactions() ([]*ledger.Transaction, error) {
columnWidth = 132
}

parsedStartDate, tstartErr := time.Parse(transactionDateFormat, startString)
parsedEndDate, tendErr := time.Parse(transactionDateFormat, endString)
parsedStartDate, tstartErr := date.Parse(startString)
parsedEndDate, tendErr := date.Parse(endString)

if tstartErr != nil || tendErr != nil {
return nil, errors.New("unable to parse start or end date string argument")
Expand Down

0 comments on commit bae70bb

Please sign in to comment.