Created
February 10, 2020 13:55
-
-
Save Daniel-Worrall/f3e1bd81b74bbf843d0ad5784f5c05ff to your computer and use it in GitHub Desktop.
Crystal Ordinal Suffix
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
day = 12 | |
suffix = case {day % 10, day % 100} | |
when {.==(1), .!=(11)} | |
"st" | |
when {.==(2), .!=(12)} | |
"nd" | |
when {.==(3), .!=(13)} | |
"rd" | |
else | |
"th" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment