Review: The HTC Pure (Touch Diamond2) from AT&T
October 20, 2009 – 11:39 am | Comments

Just prior to the official release of Windows Phone 6.5 on October 6th at&t released the HTC Pure which  is at&t’s version of the Touch Diamond 2. I have been using  the original Tilt …

Read the full story »
Mobility Site Minute

Check out our podcast, the Mobilitysite Minute. Quick news, views, and interviews.

Mobilitysite Contests

The lastest Mobilitysite.com Contests. What can you win today?

Mobility Site Videos

Video reviews, 1st looks, and demos of the hottest mobile devices.

Mobilitysite Polls

Our polls help get our reader’s take on what’s happening in Mobility.

Mobilitysite Reviews

Mobilitysite reviews take you deep into the hottest mobile devices, software and accessories.

Home » General

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

Posted by Zealot on January 5, 2009 – 3:59 pm
closeThis post was published 10 months 1 day ago which may make its actuality or expire date not be valid anymore. This site is not responsible for any misunderstanding.

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 Digg Post to Facebook

Zealot (444 Posts) - Website | Twitter | Facebook

By day a department manager and writer for a major network device vendor...by night Zealot stalks the mean magnetic streets, striking fear into the hearts of bandwidth abusers and theme park mascots. Zealot has been involved with mobile devices for more than a decade now, starting off with dumb phones, moving to PDAs and then to smartphones, notebooks and netbooks with the odd PMP thrown in. Most of his mobile time currently is spent on a Treo Pro, Zune HD, Thinkpad T61, Gigabyte M912M or a Hackintoshed Compaq Mini 704. He proudly groks the Geek community and considers himself a Neo Maxi Zune Dweebie (thanks Will Wheaton!).





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.
  • 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