diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-03-07 08:11:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-07 08:11:13 -0500 |
| commit | 34931b46ed9ebb06e9555d6e62c98c70dc460d59 (patch) | |
| tree | 7abefe0115f24ea94a007827a8e8239198b3e585 /todolist/parser.go | |
| parent | 7e50f18e5ed99abb58d3235b0060fc11ba9aa83d (diff) | |
| parent | ee5353cf832a2fec57eacb77396a443e6d6a5b9e (diff) | |
Merge pull request #35 from DmitriyMV/fix/time
Remove github.com/jinzhu/now.
Diffstat (limited to 'todolist/parser.go')
| -rw-r--r-- | todolist/parser.go | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/todolist/parser.go b/todolist/parser.go index 6cf1967..24a4016 100644 --- a/todolist/parser.go +++ b/todolist/parser.go @@ -7,8 +7,6 @@ import ( "strconv" "strings" "time" - - "github.com/jinzhu/now" ) type Parser struct{} @@ -79,9 +77,9 @@ func (p *Parser) Due(input string, day time.Time) string { case "none": return "" case "today", "tod": - return now.BeginningOfDay().Format("2006-01-02") + return bod(time.Now()).Format("2006-01-02") case "tomorrow", "tom": - return now.BeginningOfDay().AddDate(0, 0, 1).Format("2006-01-02") + return bod(time.Now()).AddDate(0, 0, 1).Format("2006-01-02") case "monday", "mon": return p.monday(day) case "tuesday", "tue": @@ -97,8 +95,8 @@ func (p *Parser) Due(input string, day time.Time) string { case "sunday", "sun": return p.sunday(day) case "next week": - n := now.BeginningOfDay() - return now.New(n).Monday().AddDate(0, 0, 7).Format("2006-01-02") + n := bod(time.Now()) + return getNearestMonday(n).AddDate(0, 0, 7).Format("2006-01-02") } return p.parseArbitraryDate(res, time.Now()) } @@ -137,37 +135,37 @@ func (p *Parser) parseArbitraryDateWithYear(_date string, year int) time.Time { } func (p *Parser) monday(day time.Time) string { - mon := now.New(day).Monday() + mon := getNearestMonday(day) return p.thisOrNextWeek(mon, day) } func (p *Parser) tuesday(day time.Time) string { - tue := now.New(day).Monday().AddDate(0, 0, 1) + tue := getNearestMonday(day).AddDate(0, 0, 1) return p.thisOrNextWeek(tue, day) } func (p *Parser) wednesday(day time.Time) string { - tue := now.New(day).Monday().AddDate(0, 0, 2) + tue := getNearestMonday(day).AddDate(0, 0, 2) return p.thisOrNextWeek(tue, day) } func (p *Parser) thursday(day time.Time) string { - tue := now.New(day).Monday().AddDate(0, 0, 3) + tue := getNearestMonday(day).AddDate(0, 0, 3) return p.thisOrNextWeek(tue, day) } func (p *Parser) friday(day time.Time) string { - tue := now.New(day).Monday().AddDate(0, 0, 4) + tue := getNearestMonday(day).AddDate(0, 0, 4) return p.thisOrNextWeek(tue, day) } func (p *Parser) saturday(day time.Time) string { - tue := now.New(day).Monday().AddDate(0, 0, 5) + tue := getNearestMonday(day).AddDate(0, 0, 5) return p.thisOrNextWeek(tue, day) } func (p *Parser) sunday(day time.Time) string { - tue := now.New(day).Monday().AddDate(0, 0, 6) + tue := getNearestMonday(day).AddDate(0, 0, 6) return p.thisOrNextWeek(tue, day) } |
