Created
December 15, 2020 18:21
-
-
Save karakanb/60f78f20cfa2154b8021b81615cb3da0 to your computer and use it in GitHub Desktop.
This file contains 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 parseWithBlackMagic(inputString string) int { | |
isAm := inputString[len(inputString)-2] == 'A' | |
number := int(inputString[0]) - '0' | |
if len(inputString) > 3 { | |
number = number*10 + int(inputString[1]) - '0' | |
} | |
if !isAm { | |
number += 12 | |
} | |
return number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment