aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuey-Liang Kao <s101062801@m101.nthu.edu.tw>2017-01-21 01:12:21 +0800
committerQuey-Liang Kao <s101062801@m101.nthu.edu.tw>2017-01-21 01:12:21 +0800
commite81c005dd64e7f206bfe5d2dd2bccc295b45fb9e (patch)
tree563c75d07877de03334d612a661413b9fd703725
parenteb807193d3ddba1c6037dc100cb422db3d68e07e (diff)
Add more helpful messages
-rw-r--r--todolist/parser.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/todolist/parser.go b/todolist/parser.go
index b16dccb..62d864d 100644
--- a/todolist/parser.go
+++ b/todolist/parser.go
@@ -110,19 +110,16 @@ func (p *Parser) parseArbitraryDate(_date string, pivot time.Time) string {
func (p *Parser) parseArbitraryDateWithYear(_date string, year int) time.Time {
res := strings.Join([]string{_date, strconv.Itoa(year)}, " ")
- var date time.Time
- var err1 error
- var err2 error
- if date, err1 = time.Parse("Jan 2 2006", res); err1 == nil {
+ if date, err := time.Parse("Jan 2 2006", res); err == nil {
return date
}
- if date, err2 = time.Parse("2 Jan 2006", res); err2 == nil {
+ if date, err := time.Parse("2 Jan 2006", res); err == nil {
return date
}
fmt.Printf("Could not parse the date you gave me: %s\n", _date)
- fmt.Println(err1)
- fmt.Println(err2)
+ fmt.Println("I'm expecting a date like \"Dec 22\" or \"22 Dec\".")
+ fmt.Println("See http://todolist.site/#adding for more info.")
os.Exit(-1)
return time.Now()
}