0x00495C65 eax: totalDays returns: eax: year ebx: month edx: day
| 98 | // ebx: month |
| 99 | // edx: day |
| 100 | Date calcDate(const uint32_t totalDays) |
| 101 | { |
| 102 | constexpr auto kBaseYear = 1800; |
| 103 | constexpr auto kDaysInYear = 365; |
| 104 | constexpr auto kDaysInOlympiad = (365 * 4) + 1; // Useful because the calendar that Loco uses (Julian) has a 4-year cycle. |
| 105 | constexpr auto kFeb29 = 31 + 28; |
| 106 | |
| 107 | int32_t years = ((totalDays / kDaysInOlympiad) & 0xFFFF) * 4; |
| 108 | int32_t day = totalDays % kDaysInOlympiad; |
| 109 | |
| 110 | // Count the years and add an extra day for when there isn't leap year |
| 111 | if (day > kDaysInYear) |
| 112 | { |
| 113 | day -= kDaysInYear; |
| 114 | day -= 1; |
| 115 | do |
| 116 | { |
| 117 | years++; |
| 118 | day -= kDaysInYear; |
| 119 | } while (day >= 0); |
| 120 | day += kDaysInYear; |
| 121 | if (day >= kFeb29) |
| 122 | { |
| 123 | day++; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | const auto year = kBaseYear + years; |
| 128 | const auto monthDay = getMonthDay(day); |
| 129 | |
| 130 | auto result = Date(year, monthDay.first, monthDay.second); |
| 131 | result.dayOfYear = day; |
| 132 | return result; |
| 133 | } |
| 134 | |
| 135 | uint32_t calcDays(Date date) |
| 136 | { |
no test coverage detected