Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active August 10, 2022 20:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/a51dcb71f2ef652464bc863ea64aa5cc to your computer and use it in GitHub Desktop.
Save davebrny/a51dcb71f2ef652464bc863ea64aa5cc to your computer and use it in GitHub Desktop.
(autohotkey) - add an ordinal suffix to a number: 1st, 2nd, 3rd
ordinal(number) {
stringRight, last_digit, number, 1
stringRight, last_two , number, 2
if (last_digit = 1)
suffix := "st"
else if (last_digit = 2)
suffix := "nd"
else if (last_digit = 3)
suffix := "rd"
else suffix := "th"
if last_two contains 11,12,13
suffix := "th"
return number . suffix
}
/*
[script info]
description = add an ordinal suffix to a number: 1st, 2nd, 3rd
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment