parallaxinc / propgcc

A Port of GCC to the Parallax Propeller
Other
36 stars 17 forks source link

lib/time/localtim.c leapyear calculation seems wrong. #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A Gregorian leap year is not simply a year evenly divisible by 4.

Years evenly divisible by 100 are not leap years unless
the year is evenly divisible by 400.

For example: 2000 and 2400 are leap years, but 1900 and 2100 are not.

Original issue reported on code.google.com by jsden...@gmail.com on 5 Mar 2012 at 7:30

GoogleCodeExporter commented 9 years ago
The bug arose because the original version of the code was for a signed time_t, 
for which this issue doesn't arise (2100 is outside the range, and 1900 is just 
outside as well). We're using unsigned time_t now, so 2100 does have to be 
handled. I've checked in code and tests for this.

Original comment by ersm...@hfx.eastlink.ca on 13 Mar 2012 at 1:51