more intuitive leap year check

This commit is contained in:
Tobias Brunner 2009-05-14 18:58:17 +02:00
parent 24bb9fdbf7
commit 5020a456c0

View File

@ -381,8 +381,8 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
tm_leap = tm_leap_4 - tm_leap_100 + tm_leap_400 - tm_leap_1970;
/* if date later then February, is the current year a leap year? */
if ((tm_mon > 1 && 4*(tm_leap_4 + 1) == tm_year) &&
(100*(tm_leap_100 + 1) != tm_year || 400*(tm_leap_400 + 1) == tm_year))
if (tm_mon > 1 && (tm_year % 4 == 0) &&
(tm_year % 100 != 0 || tm_year % 400 == 0))
{
tm_leap++;
}