Skip to content
Permalink
Browse files

Add support for noon and midnight

  • Loading branch information...
frioux committed Jun 17, 2019
1 parent 65aaa44 commit a18080061a01eed5c4d64061d5f57491534aa783
Showing with 7 additions and 0 deletions.
  1. +5 −0 internal/reminders/reminders.go
  2. +2 −0 internal/reminders/reminders_test.go
@@ -64,6 +64,11 @@ func Parse(now time.Time, message string) (time.Time, string, error) {
if m[WHEN] != "" {
when := strings.ToLower(m[WHEN])

if when == "noon" {
when = "12:00pm"
} else if when == "midnight" {
when = "12:00am"
}
for _, format := range []string{"3:04pm", "3pm"} {
clock, err := time.Parse(format, when)
if err != nil {
@@ -54,6 +54,8 @@ func TestParse(t *testing.T) {
{"remind me to frioux at 10am", "frioux", now.Add(10 * time.Hour), false},
{"remind me to frioux at 10AM", "frioux", now.Add(10 * time.Hour), false},
{"remind me to frioux at 10:01am", "frioux", now.Add(10*time.Hour + time.Minute), false},
{"remind me to frioux at noon", "frioux", time.Date(2012, 12, 12, 12, 0, 0, 0, LA), false},
{"remind me to frioux at midnight", "frioux", time.Date(2012, 12, 12, 0, 0, 0, 0, LA), false},
}

for _, a := range assertions {

0 comments on commit a180800

Please sign in to comment.
You can’t perform that action at this time.