View Single Post
Old 12-31-2008, 08:30 PM   #15 (permalink)
twhoffman
Zewbie
 
Join Date: Dec 2008
Posts: 6
twhoffman is on a distinguished road
Default

Quote:
Originally Posted by freshlogic View Post
I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug:
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;
    }
}

Last edited by twhoffman; 12-31-2008 at 08:32 PM.



twhoffman is offline   Reply With Quote