diff options
author | hop311 <hop3114@gmail.com> | 2023-12-02 16:48:08 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-12-02 20:14:29 +0100 |
commit | 4a899c1a9e83ab9476b85522751081be434caa35 (patch) | |
tree | f1f6276c91beceecdfd9b09083d1c91ea8b41b60 /src/openvic-simulation/types/Date.cpp | |
parent | cd6875d5e0ca5e2545fd0e1647678cd18a6c81c2 (diff) |
Crime+event modifier loading + misc UI backend
Diffstat (limited to 'src/openvic-simulation/types/Date.cpp')
-rw-r--r-- | src/openvic-simulation/types/Date.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/openvic-simulation/types/Date.cpp b/src/openvic-simulation/types/Date.cpp index 1b15e45..7356768 100644 --- a/src/openvic-simulation/types/Date.cpp +++ b/src/openvic-simulation/types/Date.cpp @@ -100,6 +100,12 @@ std::ostream& OpenVic::operator<<(std::ostream& out, Timespan const& timespan) { return out << timespan.to_string(); } +const std::string Date::MONTH_NAMES[MONTHS_IN_YEAR] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", + "December" +}; + Timespan Date::_date_to_timespan(year_t year, month_t month, day_t day) { month = std::clamp<month_t>(month, 1, MONTHS_IN_YEAR); day = std::clamp<day_t>(day, 1, DAYS_IN_MONTH[month - 1]); @@ -208,6 +214,15 @@ bool Date::in_range(Date start, Date end) const { return start <= *this && *this <= end; } +std::string const& Date::get_month_name() const { + const month_t month = get_month(); + if (1 <= month && month <= MONTHS_IN_YEAR) { + return MONTH_NAMES[month - 1]; + } + static const std::string invalid_month_name = "Invalid Month"; + return invalid_month_name; +} + std::string Date::to_string() const { std::stringstream ss; ss << *this; |