Last active
August 10, 2022 20:12
-
-
Save davebrny/a51dcb71f2ef652464bc863ea64aa5cc to your computer and use it in GitHub Desktop.
(autohotkey) - add an ordinal suffix to a number: 1st, 2nd, 3rd
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
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