The code that allegedly broke the Zune

midoriw:

marco:

Via jstn.

while (days > 365) {
    if (IsLeapYear(year)) {
        if (days > 366) {
            days -= 366;
            year += 1;
        }
    } else {
        days -= 365;
        year += 1;
    }
}

Out of curiosity, why was this being rewritten by Freescale or Microsoft at all? This has been a solved problem for a very long time.

(Also, this is very ugly C style in many places. I expected better from Microsoft.)

Also, who hard-codes magic numbers like that? So many things wrong with this picture.