]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Revert "cal: simplify leap year rule"
authorKarel Zak <kzak@redhat.com>
Thu, 14 Dec 2017 12:19:08 +0000 (13:19 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 14 Dec 2017 12:19:08 +0000 (13:19 +0100)
It was mistake, we use extra rule for date < 1752 from the beginning
and another calculations depends on this.

This reverts commit b9bd8dc267a71611859496bff29e329868273714.

misc-utils/cal.c

index 70a3d96c4093f3ebe1fea75611a232781b1aa51a..f56b991dc13537c1cbbdc2afec35c357d624a977 100644 (file)
@@ -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)