aboutsummaryrefslogtreecommitdiff
path: root/src/utils.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-04-29 14:17:08 -0400
committerYour Name <you@example.com>2021-04-29 14:17:08 -0400
commit5a813a75412ac9b8fadb90c9abd46dd95aee8e9b (patch)
tree75c5466d459c793430a6481cd276a624cd843794 /src/utils.cc
parentcd57ad6e208728bafcbc8c7d7b85d88603706978 (diff)
downloaddmtool-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.cc18
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;
+}