Z-Day: The Morning After (More or Less)
OK, now we all know that the problem was connected to the leap year, and that almost all of the Zune 30s are now indeed debricked. The world did NOT end, no black holes were suddenly formed at the Earth’s core….oh no, wait…that’s the Hadron Collider Thingie, the busted one. Well, umm…nothing REALLY TRULY AWFUL happened due to a day without Zune 30s…did it?
So what EXACTLY went wrong?
Well, thankfully Yahoo Tech News is here to explain it all to us, with an impressive assist from AeroXperience’s Bryant Zadegan.
Apparently the code that did the dirty deed was…..
#define ORIGINYEAR 1980 BOOL ConvertDays(UINT32 days, SYSTEMTIME* lpTime){ int dayofweek, month, year; UINT8 *month_tab;
//Calculate current day of the week dayofweek = GetDayOfWeek(days);
year = ORIGINYEAR;
while (days > 365) { if (IsLeapYear(year)) { if (days > 366) { days -= 366; year += 1; } } else { days -= 365; year += 1; } }
Clear?
All Greek to you (like it is to me)?
After the jump, see the explanation Yahoo Tech News offered we laymen (and laywomen).
For all the non-coders out there, here’s what happened. According to Zadegan, the code is designed to calculate out the year by looking at the number of days that has elapsed since a predefined ORIGINYEAR of January 1, 1980. The operating system keeps on subtracting 365 days (or 366, in the case of a leap year) from the total number of days, adding one to the year value, until it can no longer do so–thus makes the correct year.
If you’re sharp, you will have noticed the single botched element in the code. On a leap year, there are 366 days in a year. December 31 is the 366th day of the year. The amount 366 is greater than 365, but it is not greater than 366. What happens then? The loop cycles back to the beginning to check the 366-day amount that’s remaining. It’s greater than 365 days, passing through that line of code. It’s not greater than 366 days, so nothing happens. The amount loops back through the code, and loops back through the code, and…











