Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Add support for noon and midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
frioux committed Jun 17, 2019
1 parent 65aaa44 commit a180800
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/reminders/reminders.go
Expand Up @@ -64,6 +64,11 @@ func Parse(now time.Time, message string) (time.Time, string, error) {
if m[WHEN] != "" { if m[WHEN] != "" {
when := strings.ToLower(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"} { for _, format := range []string{"3:04pm", "3pm"} {
clock, err := time.Parse(format, when) clock, err := time.Parse(format, when)
if err != nil { if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/reminders/reminders_test.go
Expand Up @@ -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 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 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 { for _, a := range assertions {
Expand Down

0 comments on commit a180800

Please sign in to comment.