Skip to content

Instantly share code, notes, and snippets.

@Daniel-Worrall
Created February 10, 2020 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daniel-Worrall/f3e1bd81b74bbf843d0ad5784f5c05ff to your computer and use it in GitHub Desktop.
Save Daniel-Worrall/f3e1bd81b74bbf843d0ad5784f5c05ff to your computer and use it in GitHub Desktop.
Crystal Ordinal Suffix
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