From 35e2e40ce6b4957aee1df118823d3b70cd41aee3 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Fri, 23 May 2025 22:15:10 -0600 Subject: [PATCH] oooo onedayoff ok --- cmd/cli/main.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 574d043..0ecb205 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -266,20 +266,23 @@ func Main() { continue } - err := "missing" + msg := "missing" - t, _ := time.ParseInLocation(transaction.Date, "2006-01-02", time.Local) - dayBefore := t.Add(-24 * time.Hour).Format("2006-01-02") - dayAfter := t.Add(-24 * time.Hour).Format("2006-01-02") + ts, err := time.ParseInLocation("2006-01-02", transaction.Date, time.Local) + if err != nil { + panic(err) + } + dayBefore := ts.Add(-24 * time.Hour).Format("2006-01-02") + dayAfter := ts.Add(-24 * time.Hour).Format("2006-01-02") if inDay(dayBefore, transaction) || inDay(dayAfter, transaction) { - err = "1dayoff" + msg = "1dayoff" } prefix := " " if transaction.Status != "posted" { prefix = "! " } - fmt.Printf("[%s] %s $%7.2f %s%s (%s)\n", err, transaction.Date, transaction.Amount, prefix, transaction.Details.CounterParty.Name, transaction.Description) + fmt.Printf("[%s] %s $%7.2f %s%s (%s)\n", msg, transaction.Date, transaction.Amount, prefix, transaction.Details.CounterParty.Name, transaction.Description) } } case "reg":