From f4fe01543efcf33b86d22eb34736b54fbf2da3c3 Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Fri, 3 Mar 2017 18:40:42 -0500 Subject: Fix agenda bug Previously, running `todo agenda` was also listing todos with no due date. Now, it won't do that. --- todolist/date_filter.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'todolist') diff --git a/todolist/date_filter.go b/todolist/date_filter.go index 2bf51e2..0575e6a 100644 --- a/todolist/date_filter.go +++ b/todolist/date_filter.go @@ -17,7 +17,7 @@ func NewDateFilter(todos []*Todo) *DateFilter { } func (f *DateFilter) FilterDate(input string) []*Todo { - agendaRegex, _ := regexp.Compile(`agenda .*$`) + agendaRegex, _ := regexp.Compile(`agenda.*$`) if agendaRegex.MatchString(input) { return f.filterAgenda(now.BeginningOfDay()) } @@ -57,6 +57,9 @@ func (f *DateFilter) filterAgenda(pivot time.Time) []*Todo { var ret []*Todo for _, todo := range f.Todos { + if todo.Due == "" { + continue + } dueTime, _ := time.ParseInLocation("2006-01-02", todo.Due, f.Location) if dueTime.Before(pivot) || todo.Due == pivot.Format("2006-01-02") { ret = append(ret, todo) -- cgit v1.3