[LEAPSECS] Leap year day-count bugs, then and now

Tom Van Baak tvb at LeapSecond.com
Fri Jan 2 11:52:38 EST 2009



> Also, the comments section of that article includes the actual code

> behind the Zume bug, which involves the system getting put in an

> infinite loop on reaching a day number of 366, even though the code

> did in fact attempt to be cognizant of leap years.


Dan, thanks for the rtt.c link (http://pastie.org/349916.txt)
The piece of code in question starts at line 259:

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

The file contains quite a number of date/time related functions,
not unlike those found in almost any application, library, or
operating system.

I recommend anyone on the list take a look at this file, not as a
swipe at Zune or the company that makes it, or Freescale, who
apparently wrote the code, but as a typical example of the state
of date/time handling in modern software.

Then, if leap seconds were to matter to a device like Zune, ask
yourself what would have to change in the code the handle leap
seconds correctly as well as leap years.

/tvb




More information about the LEAPSECS mailing list