summaryrefslogtreecommitdiff
path: root/i386/i386at/rtc.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2017-01-24 01:56:00 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2017-01-24 01:56:00 +0100
commitdc5486ba8801625069fc6172b03e897612f42a90 (patch)
treede3c8b460d7cf5afe5d42be49ec8f1a7eb52f908 /i386/i386at/rtc.c
parent941d462425fb2692fd9ffea1ab03e927697fcfb0 (diff)
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.
Diffstat (limited to 'i386/i386at/rtc.c')
-rw-r--r--i386/i386at/rtc.c19
1 files changed, 18 insertions, 1 deletions
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