diff options
| author | Grant Ammons <gammons@gmail.com> | 2016-05-12 07:13:51 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2016-05-12 07:13:51 -0400 |
| commit | 5cdaefd17b999aa554485ca30246e7469affe1e4 (patch) | |
| tree | b6c27a2d54267b6dfe33cb1c9128821628a81d27 /todolist | |
| parent | 2b4a2ed42ef32ce2d118a79207124ee6b30db850 (diff) | |
Fix issue with parsing specific dates
Diffstat (limited to 'todolist')
| -rw-r--r-- | todolist/parser.go | 5 | ||||
| -rw-r--r-- | todolist/parser_test.go | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/todolist/parser.go b/todolist/parser.go index e06545e..c0c9c3c 100644 --- a/todolist/parser.go +++ b/todolist/parser.go @@ -48,8 +48,9 @@ func (p *Parser) Contexts(input string) []string { } func (p *Parser) hasDue(input string) bool { - r, _ := regexp.Compile(`due \w+$`) - return r.MatchString(input) + r1, _ := regexp.Compile(`due \w+$`) + r2, _ := regexp.Compile(`due \w+ \d+$`) + return (r1.MatchString(input) || r2.MatchString(input)) } func (p *Parser) Due(input string, day time.Time) string { diff --git a/todolist/parser_test.go b/todolist/parser_test.go index 2134a86..e913437 100644 --- a/todolist/parser_test.go +++ b/todolist/parser_test.go @@ -69,6 +69,14 @@ func TestDueTomorrow(t *testing.T) { } } +func TestDueSpecific(t *testing.T) { + assert := assert.New(t) + parser := &Parser{} + fmt.Println("Parsing new todo") + todo := parser.ParseNewTodo("do this thing with @bob and @mary due jun 1") + assert.Equal("2016-06-01", todo.Due) +} + func TestMondayOnSunday(t *testing.T) { assert := assert.New(t) parser := &Parser{} @@ -108,6 +116,7 @@ func TestDueOnSpecificDate(t *testing.T) { assert := assert.New(t) parser := &Parser{} assert.Equal("2016-05-02", parser.Due("due may 2", time.Now())) + assert.Equal("2016-06-01", parser.Due("due jun 1", time.Now())) } func TestDueOnSpecificDateEuropean(t *testing.T) { |
