diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-06-19 12:58:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-19 12:58:27 -0400 |
| commit | dafb74428d8a16b28533aa25f83f25ea255c18a3 (patch) | |
| tree | b5df1531dec03b2a2beb3a1ea05b42938684b937 /todolist/parser.go | |
| parent | 4a91b284cc1840ad4dc4e60e831c8c6e3de283de (diff) | |
| parent | 0d815737ccb61a6664a9943516518decdddf0bb2 (diff) | |
Merge pull request #68 from gammons/code-cleanup
Fix parsing a todo with europe date format
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 { |
