From: Karel Zak Date: Thu, 14 Dec 2017 12:19:08 +0000 (+0100) Subject: Revert "cal: simplify leap year rule" X-Git-Tag: v2.32-rc1~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9c650106b6db14dd4d162a9f1ff697bd790dc63;p=thirdparty%2Futil-linux.git Revert "cal: simplify leap year rule" It was mistake, we use extra rule for date < 1752 from the beginning and another calculations depends on this. This reverts commit b9bd8dc267a71611859496bff29e329868273714. --- diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 70a3d96c40..f56b991dc1 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -531,9 +531,13 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } +/* leap year -- account for gregorian reformation in 1752 */ static int leap_year(int32_t year) { - return ( !(year % 4) && (year % 100) ) || !(year % 400); + if (year <= REFORMATION_YEAR) + return !(year % 4); + else + return ( !(year % 4) && (year % 100) ) || !(year % 400); } static void init_monthnames(struct cal_control *ctl)