diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-06-12 08:13:15 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2017-06-12 08:13:15 -0400 |
| commit | c50de79c4828dbb4f9b5c23bf9e00ea4dea38a01 (patch) | |
| tree | 1c6a3a75ca21299e160778f9dd5fddb3be9f3828 /todolist/parser.go | |
| parent | cb849e5a8e0280d9fc10941d915f6252a0ad1cdc (diff) | |
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`.
Diffstat (limited to 'todolist/parser.go')
| -rw-r--r-- | todolist/parser.go | 6 |
1 files changed, 3 insertions, 3 deletions
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 { |
