From 5a813a75412ac9b8fadb90c9abd46dd95aee8e9b Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 29 Apr 2021 14:17:08 -0400 Subject: Removed data files from repo --- src/utils.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/utils.cc') 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; +} -- cgit v1.2.3