I prefer:
for (;;) {
int days_in_year = IsLeapYear(year) ? 366 : 365;
if (days <= days_in_year) break;
days -= days_in_year;
year += 1;
}