View Single Post
Old 01-08-2009, 01:03 PM   #83
MercifulBoss
Experienced Zuner
 
Join Date: Jun 2008
Location: On a single planets of many in this universe....
Posts: 150
MercifulBoss is on a distinguished road
Default

Quote:
Originally Posted by twhoffman View Post
That would prevent the infinite loop, but would introduce a new bug where it advances the year on the last day of a leap year. It would have thought today was December 31, 2009. That's better than locking up, but it also would mean that all time-limited DRM media would stop working. So, if you have a Zune Pass, none of your songs would play.

What's needed is a break within an else like this (I hope, my C's a little rusty, and was never that good to begin with):

Code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
        else
        {
            break;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}
Why would doing "days >= 366" advance forward a year? Wouldn't it simply say that if days = 366 or greater than 366 then do the below code?




MercifulBoss is offline   Reply With Quote