From 29242153da9632b1decef8491fc5549719c85d7b Mon Sep 17 00:00:00 2001 From: Stuart Skelton Date: Thu, 20 Jul 2017 00:02:12 +0100 Subject: Added filterToExactDate. Filters the todolist to a certain date. --- todolist/date_filter.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/todolist/date_filter.go b/todolist/date_filter.go index 8d64484..13c3705 100644 --- a/todolist/date_filter.go +++ b/todolist/date_filter.go @@ -68,7 +68,7 @@ func (f *DateFilter) filterAgenda(pivot time.Time) []*Todo { return ret } -func (f *DateFilter) filterToday(pivot time.Time) []*Todo { +func (f *DateFilter) filterToExactDate(pivot time.Time) []*Todo { var ret []*Todo for _, todo := range f.Todos { if todo.Due == pivot.Format("2006-01-02") { @@ -78,6 +78,11 @@ func (f *DateFilter) filterToday(pivot time.Time) []*Todo { return ret } + +func (f *DateFilter) filterToday(pivot time.Time) []*Todo { + return f.filterToExactDate(pivot) +} + func (f *DateFilter) filterDay(pivot time.Time, day time.Weekday) []*Todo { var ret []*Todo filtered := f.filterThisWeek(pivot) @@ -92,14 +97,8 @@ func (f *DateFilter) filterDay(pivot time.Time, day time.Weekday) []*Todo { } func (f *DateFilter) filterTomorrow(pivot time.Time) []*Todo { - var ret []*Todo pivot = pivot.AddDate(0, 0, 1) - for _, todo := range f.Todos { - if todo.Due == pivot.Format("2006-01-02") { - ret = append(ret, todo) - } - } - return ret + return f.filterToExactDate(pivot) } func (f *DateFilter) filterThisWeek(pivot time.Time) []*Todo { -- cgit v1.3