diff --git a/calendar/engine/daily_summary.go b/calendar/engine/daily_summary.go index a08d9768..80f8e307 100644 --- a/calendar/engine/daily_summary.go +++ b/calendar/engine/daily_summary.go @@ -5,6 +5,7 @@ package engine import ( "fmt" + "strings" "time" "github.com/pkg/errors" @@ -44,7 +45,7 @@ func (m *mscalendar) SetDailySummaryPostTime(user *User, timeStr string) (*store return nil, err } - t, err := time.Parse(time.Kitchen, timeStr) + t, err := time.Parse(time.Kitchen, convertMeridiemToUpperCase(timeStr)) if err != nil { return nil, errors.New("Invalid time value: " + timeStr) } @@ -291,3 +292,17 @@ func getTodayHoursForTimezone(now time.Time, timezone string) (start, end time.T end = start.Add(24 * time.Hour) return start, end } + +func convertMeridiemToUpperCase(timeStr string) string { + if len(timeStr) < 2 { + return timeStr + } + + meridiem := strings.ToUpper(timeStr[len(timeStr)-2:]) + + if meridiem == "AM" || meridiem == "PM" { + return timeStr[:len(timeStr)-2] + meridiem + } + + return timeStr +}