From cb68655d2d9e1fb54891f025dcff15ff5ed74e73 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 4 Jul 2018 15:50:41 +0200 Subject: [PATCH] Localtime: clarify is_leap_year() working with comments. --- src/localtime.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/localtime.c b/src/localtime.c index 8c1ff4955..186c8e3c6 100644 --- a/src/localtime.c +++ b/src/localtime.c @@ -50,10 +50,10 @@ * designed to work with what time(NULL) may return, and to support Redis * logging of the dates, it's not really a complete implementation. */ static int is_leap_year(time_t year) { - if (year % 4) return 0; - else if (year % 100) return 1; - else if (year % 400) return 0; - else return 1; + if (year % 4) return 0; /* A year divisible by 4 is not leap. */ + else if (year % 100) return 1; /* If div by 4 and not 100 is surely leap. */ + else if (year % 400) return 0; /* If div by 100 *and* 400 is not leap. */ + else return 1; /* If div by 100 and not by 400 is leap. */ } void nolocks_localtime(struct tm *tmp, time_t t, time_t tz, int dst) {