diff options
author | Your Name <you@example.com> | 2021-04-29 14:17:08 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-04-29 14:17:08 -0400 |
commit | 5a813a75412ac9b8fadb90c9abd46dd95aee8e9b (patch) | |
tree | 75c5466d459c793430a6481cd276a624cd843794 /src/utils.cc | |
parent | cd57ad6e208728bafcbc8c7d7b85d88603706978 (diff) | |
download | dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.tar.gz dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.tar.bz2 dmtool-5a813a75412ac9b8fadb90c9abd46dd95aee8e9b.zip |
Removed data files from repo
Diffstat (limited to 'src/utils.cc')
-rw-r--r-- | src/utils.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils.cc b/src/utils.cc index d071fe6..a44eced 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -82,3 +82,21 @@ std::string utils::getCostString(int coppers) { } return utils::join(parts, ", "); } + +std::string utils::toOrdinal(std::size_t number) { + std::string suffix = "th"; + if (number % 100 < 11 || number % 100 > 13) { + switch (number % 10) { + case 1: + suffix = "st"; + break; + case 2: + suffix = "nd"; + break; + case 3: + suffix = "rd"; + break; + } + } + return std::to_string(number) + suffix; +} |