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 1 commit
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, convertToUpperCaseTime(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 convertToUpperCaseTime(timeStr string) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to reflect that it is only changing the case for the meridiems?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done @wiggin77 .
Updated it to convertMeridiemToUpperCase

if len(timeStr) < 2 {
return timeStr
}

period := timeStr[len(timeStr)-2:]

if strings.ToLower(period) == "am" || strings.ToLower(period) == "pm" {
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
return timeStr[:len(timeStr)-2] + strings.ToUpper(period)
}

return timeStr
}
Loading