The real reason why the Zune died on December 31 – faulty code

By on

On December 31, the final day of the year of 2008, gave users of the Microsoft Zune some frustration after the player would not turn on. Now, a person from zuneboards.com has claimed that he has found the problem that caused the mass shutdown – and it has to do something with the time.

“The function keeps subtracting either 365 or 366 until it gets down to less than a year’s worth of days, which it then turns into the month and day of month,” user itsnotabigtruck wrote on the boards. “Thing is, in the case of the last day of a leap year, it keeps going until it hits 366.”

“Thanks to the if (days > 366), it stops subtracting anything if the loop happens to be on a leap year. But 366 is too large to break out of the main loop, meaning that the Zune keeps looping forever and doesn’t do anything else.”

The affected piece of code is this:

year = ORIGINYEAR; /* = 1980 */

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

This piece of code, if left unfixed, means that all the Zunes will not work on the last day of every leap year – meaning that it will not work on December 31, 2012; since that is the 366th day of the year 2012. Ouch.

Thanks for coming onboard!
We're excited to have you.