diff --git a/src/date.cpp b/src/date.cpp index af75fa4bd6..3961c4ff1a 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -281,6 +281,25 @@ bool CalTime::IsCalendarFrozen(bool newgame) return settings.economy.timekeeping_units == TKU_WALLCLOCK && settings.economy.minutes_per_calendar_year == CalTime::FROZEN_MINUTES_PER_YEAR; } +CalTime::Day CalTime::NumberOfDaysInMonth(Year year, Month month) +{ + switch (month) { + case 0: return 31; + case 1: return CalTime::IsLeapYear(year) ? 29 : 28; + case 2: return 31; + case 3: return 30; + case 4: return 31; + case 5: return 30; + case 6: return 31; + case 7: return 31; + case 8: return 30; + case 9: return 31; + case 10: return 30; + case 11: return 31; + default: NOT_REACHED(); + } +} + bool EconTime::UsingWallclockUnits(bool newgame) { if (newgame) return (_settings_newgame.economy.timekeeping_units == TKU_WALLCLOCK); diff --git a/src/date_type.h b/src/date_type.h index 9bd4f75f41..5b06864a26 100644 --- a/src/date_type.h +++ b/src/date_type.h @@ -197,6 +197,8 @@ struct CalTime : public DateDetail::BaseTime { static bool IsCalendarFrozen(bool newgame = false); + static Day NumberOfDaysInMonth(Year year, Month month); + /** * Calculate the year of a given date. * @param date The date to consider.