From dc5486ba8801625069fc6172b03e897612f42a90 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 24 Jan 2017 01:56:00 +0100 Subject: Fix bissextile years computation In practice, fixes 2100, 2200, 2300, 2500, 2600, 2700, etc. * i386/i386at/rtc.c (yeartoday): Make years divisible by 100 but not divisible by 400 non-bisextile. --- i386/i386at/rtc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/i386/i386at/rtc.c b/i386/i386at/rtc.c index 01e09772..b284c332 100644 --- a/i386/i386at/rtc.c +++ b/i386/i386at/rtc.c @@ -109,7 +109,24 @@ static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int yeartoday(int year) { - return((year%4) ? 365 : 366); + if (year%4) + /* Not divisible by 4, not bissextile */ + return 365; + + /* Divisible by 4 */ + if (year % 100) + /* Not divisible by 100, bissextile */ + return 366; + + /* Divisible by 100 */ + if (year % 400) + /* Not divisible by 400, not bissextile */ + return 365; + + /* Divisible by 400 */ + /* Rules for 2000 and further have not been officially decided yet. + * 2000 was made bissextile. */ + return 366; } int -- cgit v1.2.3