As I see it, anytime days > 367 (if leap year) or days > 366 (if not), the program should SCREAM. --Dan << [Reminds me of the "phase of the moon" bug ... http://www.ccil.org/jargon/jargon_31.html] comp.risks had more info on the Zune calendar freeze bug:
The issue is an infinite loop:
while (days > 365) { if (IsLeapYear(year)) { if (days > 366) { days -= 366; year += 1; } } else { days -= 365; year += 1; } }
Under normal circumstances, this works just fine. The function keeps subtracting either 365 or 366 until it gets down to less than a year's worth of days, which it then turns into the month and day of month. Thing is, in the case of the last day of a leap year, it keeps going until it hits 366. Thanks to the if (days > 366), it stops subtracting anything if the loop happens to be on a leap year. But 366 is too large to break out of the main loop, meaning that the Zune keeps looping forever and doesn't do anything else.
_____________________________________________________________________ "It don't mean a thing if it ain't got that certain je ne sais quoi." --Peter Schickele