Thursday, January 01, 2009

Happy New Year for Zune Owners

Here's an exercise for you. What happens when days = 366 in the code below? Maybe the better question is what happens when programmers skip their morning coffee when they reinvent the wheel and write a "simple" date parser with leap year detection? This code was loaded on every 30 GB Zune. Check out the offending module and read the coverage on Engadget. This presents a great case for unit testing!





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



What's in your firmware??

No comments:

High Quality VHS Capture on a Budget in 2020 - Part I: Choosing a VCR

Introduction I recently inherited a few dozen family videos on VHS and VHS-C going back to the early 1980's. Along with this haul came a...