Home Forums Resources Shopping Quick Links Send Tips

Z-Day: The Morning After (More or Less)

zune-gadget-30gb-digital-media-player-pink 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…

[Post to Twitter]  [Post to Yahoo Buzz]  [Post to Delicious]  [Post to Digg]  [Post to Ping.fm]  [Post to StumbleUpon] 

Get Mobility Site via Email

You can also participate in other conversation in our active forums with 200,000 other Members. It only takes 2 minutes to sign up one time for free in the forums. Thanks for reading.
  • steve laser
    Good call Pony! Glad your education is helping us!
  • Oops, that should "days == 366". I now get a compiler error.... :D

    Steve
  • In the loop, they needed another else statement, as shown highlighted below:

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

    } else {
    days -= 365; year += 1;
    }
    }

    Of course, I'm not so sure why they need ugly loops like that. In high school, my programmable calculators worked by converting the Gregorian date (anything past somewhere in 1582) to a Julian number. The programmers should have done that with January 1, 1980, added the days, then done the Julian number-to-Gregorian date conversion.

    I don't know which would be faster, but the looping algorithm is O(n) where (if I remember correctly) the Julian number conversions were O(1).

    I need to use my Computer Science degree somewhere, right? :D

    Steve
blog comments powered by Disqus

You Should Also Check Out These Posts:

More Active Posts:

About Mobilitysite

Mobilitysite.com is a site covering Mobility News, Reviews, and Discussion. Our coverage focuses on Windows Mobile Phones and PDAs, but extends on past that as well. Tablet PC, UMPC, and Personal Media Players like the Zune and iPod are loosely covered as well. To learn more about Mobilitysite and/or Aximsite, read here. Also take time to register in our forums too. There is a wealth of information to be found inside and registering yourself in the forums also registers you with the blog portion of the site.
Mobilitysite - Aximsite - Hard Reset Guide - Got Zune

Contact Us - About Us - Privacy Policy - Advertise - News Archives - Forum Archives - Donate - Top