Codechange: Add a DateToYear function instead of dividing each time (#11173)

This commit is contained in:
Tyler Trahan
2023-08-11 08:19:54 -04:00
committed by GitHub
parent 4928ccf916
commit 6190f48df0
4 changed files with 15 additions and 5 deletions

View File

@@ -63,6 +63,16 @@ static constexpr TimerGameCalendar::Date DateAtStartOfYear(TimerGameCalendar::Ye
return (DAYS_IN_YEAR * year) + number_of_leap_years;
}
/**
* Calculate the year of a given date.
* @param date The date to consider.
* @return the year.
*/
static inline TimerGameCalendar::Year DateToYear(TimerGameCalendar::Date date)
{
return date / DAYS_IN_LEAP_YEAR;
}
/**
* The date of the first day of the original base year.
*/