aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--todo.go2
-rw-r--r--todolist/app_test.go12
-rw-r--r--todolist/date_filter.go13
-rw-r--r--todolist/parser.go2
4 files changed, 17 insertions, 12 deletions
diff --git a/todo.go b/todo.go
index 645a880..3f3c20d 100644
--- a/todo.go
+++ b/todo.go
@@ -11,7 +11,7 @@ import (
)
const (
- VERSION = "0.6"
+ VERSION = "0.7"
)
func main() {
diff --git a/todolist/app_test.go b/todolist/app_test.go
index 2fb7717..360da43 100644
--- a/todolist/app_test.go
+++ b/todolist/app_test.go
@@ -44,6 +44,18 @@ func TestAddTodoWithEuropeanDates(t *testing.T) {
assert.Equal([]string{}, todo.Contexts)
}
+func TestAddEmptyTodo(t *testing.T) {
+ assert := assert.New(t)
+ app := &App{TodoList: &TodoList{}, TodoStore: &MemoryStore{}}
+
+ app.AddTodo("a")
+ app.AddTodo("a ")
+ app.AddTodo("a\t\t\t\t")
+ app.AddTodo("a\t \t \t \t")
+
+ assert.Equal(len(app.TodoList.Data), 0)
+}
+
func TestListbyProject(t *testing.T) {
assert := assert.New(t)
app := &App{TodoList: &TodoList{}, TodoStore: &MemoryStore{}}
diff --git a/todolist/date_filter.go b/todolist/date_filter.go
index b91bee3..261e5ad 100644
--- a/todolist/date_filter.go
+++ b/todolist/date_filter.go
@@ -112,16 +112,9 @@ func (f *DateFilter) filterCompletedToday(pivot time.Time) []*Todo {
}
func (f *DateFilter) filterDay(pivot time.Time, day time.Weekday) []*Todo {
- var ret []*Todo
- filtered := f.filterThisWeek(pivot)
- for _, todo := range filtered {
- dueTime, _ := time.ParseInLocation("2006-01-02", todo.Due, f.Location)
- if dueTime.Weekday() == day {
- ret = append(ret, todo)
- }
-
- }
- return ret
+ thisWeek := NewDateFilter(f.filterThisWeek(pivot))
+ pivot = f.FindSunday(pivot).AddDate(0, 0, int(day))
+ return thisWeek.filterToExactDate(pivot, filterOnDue)
}
func (f *DateFilter) filterBetweenDatesInclusive(begin, end time.Time, filterOn func(*Todo) string) []*Todo {
diff --git a/todolist/parser.go b/todolist/parser.go
index 6ad8007..3f700af 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -12,7 +12,7 @@ import (
type Parser struct{}
func (p *Parser) ParseNewTodo(input string) *Todo {
- r, _ := regexp.Compile(`^(add|a)(\\ |) `)
+ r, _ := regexp.Compile(`^(add|a)(\s*|)`)
input = r.ReplaceAllString(input, "")
if input == "" {
return nil