MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / calcDays

Function calcDays

src/OpenLoco/src/Date.cpp:135–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 }
134
135 uint32_t calcDays(Date date)
136 {
137 constexpr auto kBaseYear = 1800;
138 constexpr auto kDaysInYear = 365;
139
140 // adds years (365 for each year + 1 for leap years)
141 auto yearDiff = date.year - kBaseYear;
142 uint32_t dayCount = (yearDiff * kDaysInYear) + (yearDiff / 4);
143
144 // add months
145 for (int month = 0; month < static_cast<uint8_t>(date.month); ++month)
146 {
147 dayCount += getMonthTotalDay(date.year, static_cast<MonthId>(month));
148 }
149
150 // add days
151 dayCount += date.day;
152
153 return dayCount;
154 }
155
156 static std::pair<MonthId, uint8_t> getMonthDay(int32_t dayOfYear)
157 {

Callers 1

initialiseDateFunction · 0.85

Calls 1

getMonthTotalDayFunction · 0.85

Tested by

no test coverage detected