Created
December 15, 2020 18:03
-
-
Save karakanb/92a52c7c3d1385ca353096f2316961ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseWithReplaceAllTrimSuffix(inputString string) int { | |
isAm := strings.HasSuffix(inputString, "AM") | |
if isAm { | |
inputString = strings.TrimSuffix(inputString, "AM") | |
} else { | |
inputString = strings.TrimSuffix(inputString, "PM") | |
} | |
number, _ := strconv.Atoi(inputString) | |
if !isAm { | |
number += 12 | |
} | |
return number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment