weekday abbreviations
This commit is contained in:
parent
064adad7cb
commit
a715625e0a
|
@ -116,12 +116,14 @@ func NewDateFromString(date string) Date {
|
|||
fallthrough
|
||||
case "no date":
|
||||
return Date{}
|
||||
|
||||
case "today":
|
||||
return Today()
|
||||
|
||||
case "tod":
|
||||
return Today()
|
||||
case "tomorrow":
|
||||
return Today().AddDays(1)
|
||||
case "tom":
|
||||
return Today().AddDays(1)
|
||||
}
|
||||
|
||||
t, err := time.Parse("2006-01-02", fmt.Sprintf("%.10s", date))
|
||||
|
@ -241,35 +243,35 @@ func ParseWeekday(wd string) (time.Weekday, bool) {
|
|||
switch lowerAndTrim(wd) {
|
||||
case "monday":
|
||||
return time.Monday, true
|
||||
case "mon":
|
||||
return time.Monday, true
|
||||
case "tuesday":
|
||||
return time.Tuesday, true
|
||||
case "tue":
|
||||
return time.Tuesday, true
|
||||
case "wednesday":
|
||||
return time.Wednesday, true
|
||||
case "wed":
|
||||
return time.Wednesday, true
|
||||
case "thursday":
|
||||
return time.Thursday, true
|
||||
case "thu":
|
||||
return time.Thursday, true
|
||||
case "friday":
|
||||
return time.Friday, true
|
||||
case "fri":
|
||||
return time.Friday, true
|
||||
case "saturday":
|
||||
return time.Saturday, true
|
||||
case "sat":
|
||||
return time.Saturday, true
|
||||
case "sunday":
|
||||
return time.Sunday, true
|
||||
case "maandag":
|
||||
return time.Monday, true
|
||||
case "dinsdag":
|
||||
return time.Tuesday, true
|
||||
case "woensdag":
|
||||
return time.Wednesday, true
|
||||
case "donderdag":
|
||||
return time.Thursday, true
|
||||
case "vrijdag":
|
||||
return time.Friday, true
|
||||
case "zaterdag":
|
||||
return time.Saturday, true
|
||||
case "zondag":
|
||||
case "sun":
|
||||
return time.Sunday, true
|
||||
default:
|
||||
return time.Monday, false
|
||||
}
|
||||
|
||||
return time.Monday, false
|
||||
}
|
||||
|
||||
func lowerAndTrim(str string) string {
|
||||
|
|
|
@ -142,6 +142,10 @@ func TestNewDateFromString(t *testing.T) {
|
|||
name: "dayname capitalized",
|
||||
input: "Monday",
|
||||
},
|
||||
{
|
||||
name: "dayname short",
|
||||
input: "mon",
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
test.Equals(t, monday, task.NewDateFromString(tc.input))
|
||||
|
@ -158,10 +162,18 @@ func TestNewDateFromString(t *testing.T) {
|
|||
name: "today",
|
||||
exp: task.Today(),
|
||||
},
|
||||
{
|
||||
name: "tod",
|
||||
exp: task.Today(),
|
||||
},
|
||||
{
|
||||
name: "tomorrow",
|
||||
exp: task.Today().Add(1),
|
||||
},
|
||||
{
|
||||
name: "tom",
|
||||
exp: task.Today().Add(1),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
test.Equals(t, tc.exp, task.NewDateFromString(tc.name))
|
||||
|
|
Loading…
Reference in New Issue