From c50de79c4828dbb4f9b5c23bf9e00ea4dea38a01 Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Mon, 12 Jun 2017 08:13:15 -0400 Subject: Fix #64, parsing a todo with europe date format * the `hasDue` function was not running, and therefore it was not parsing the due date. * Also added the beginnings of a more holistic test approach, using `app_test.go`. --- todolist/parser.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'todolist/parser.go') diff --git a/todolist/parser.go b/todolist/parser.go index 256e782..cdfb179 100644 --- a/todolist/parser.go +++ b/todolist/parser.go @@ -86,7 +86,8 @@ func (p *Parser) Contexts(input string) []string { func (p *Parser) hasDue(input string) bool { r1, _ := regexp.Compile(`due \w+$`) r2, _ := regexp.Compile(`due \w+ \d+$`) - return (r1.MatchString(input) || r2.MatchString(input)) + r3, _ := regexp.Compile(`due \d+ \w+$`) + return (r1.MatchString(input) || r2.MatchString(input) || r3.MatchString(input)) } func (p *Parser) Due(input string, day time.Time) string { @@ -137,9 +138,8 @@ func (p *Parser) parseArbitraryDate(_date string, pivot time.Time) string { d2 := p.parseArbitraryDateWithYear(_date, pivot.Year()+1) if d2.Sub(pivot) > diff1 { return d1.Format("2006-01-02") - } else { - return d2.Format("2006-01-02") } + return d2.Format("2006-01-02") } func (p *Parser) parseArbitraryDateWithYear(_date string, year int) time.Time { -- cgit v1.3