From 48b00790009d9e1a6b664312de1e13b0732fc9fe Mon Sep 17 00:00:00 2001 From: Jakub Czapiga Date: Thu, 15 Apr 2021 12:30:27 +0200 Subject: lib/rtc: Fix incomplete leap year macro Signed-off-by: Jakub Czapiga Found-by: Paul Fagerburg Change-Id: Ic434c969141c67ce317a5db0c8805de02c84eb08 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52370 Tested-by: build bot (Jenkins) Reviewed-by: Paul Fagerburg --- src/lib/rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/rtc.c b/src/lib/rtc.c index 5e03cfae1e..c5fffa0e8b 100644 --- a/src/lib/rtc.c +++ b/src/lib/rtc.c @@ -11,7 +11,7 @@ #define STARTOFTIME 1970 #define SECDAY 86400L #define SECYR (SECDAY * 365) -#define LEAP_YEAR(year) ((year) % 4 == 0) +#define LEAP_YEAR(year) (((year) % 4 == 0 && (year) % 100 != 0) || (year) % 400 == 0) #define DAYS_IN_YEAR(a) (LEAP_YEAR(a) ? 366 : 365) #define DAYS_IN_MONTH(a) (month_days[(a) - 1]) -- cgit v1.2.3