]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cal: simplify leap year rule
authorKarel Zak <kzak@redhat.com>
Mon, 13 Nov 2017 16:34:19 +0000 (17:34 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Nov 2017 16:34:19 +0000 (17:34 +0100)
Gregorian rule for leap years has been adopted by reformation in year
1782 (Calendar Act 1750), but all tools (date, SQL servers, etc. etc.)
don't care about it and apply the new rule for all year -- including
years before the reformation.

It's better to be compatible with another tools than try to be perfect :-)

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1507271
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/cal.c

index 98bdff681849be678fb7afb364585577dbe3d018..64847da3cef41b202a02e7fb8634f70ca52e609b 100644 (file)
@@ -531,13 +531,9 @@ int main(int argc, char **argv)
        return EXIT_SUCCESS;
 }
 
-/* leap year -- account for gregorian reformation in 1752 */
 static int leap_year(int32_t year)
 {
-       if (year <= REFORMATION_YEAR)
-               return !(year % 4);
-       else
-               return ( !(year % 4) && (year % 100) ) || !(year % 400);
+       return ( !(year % 4) && (year % 100) ) || !(year % 400);
 }
 
 static void init_monthnames(struct cal_control *ctl)