Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-339]: Added support for lower case meridiems(AM/PM) #438

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion calendar/engine/daily_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package engine

import (
"fmt"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Loading