public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kunit: time: use is_leap_year() helper
@ 2026-01-23  8:09 Jinjie Ruan
  2026-01-26 15:22 ` [tip: timers/core] time/kunit: Use " tip-bot2 for Jinjie Ruan
  2026-01-30 15:11 ` [PATCH] kunit: time: use " Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Jinjie Ruan @ 2026-01-23  8:09 UTC (permalink / raw)
  To: jstultz, tglx, sboyd, linux-kernel; +Cc: ruanjinjie

Use the is_leap_year() helper from rtc.h instead of
writing it by hand

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 kernel/time/time_test.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/kernel/time/time_test.c b/kernel/time/time_test.c
index 2889763165e5..7c2fb5f775eb 100644
--- a/kernel/time/time_test.c
+++ b/kernel/time/time_test.c
@@ -2,14 +2,7 @@
 
 #include <kunit/test.h>
 #include <linux/time.h>
-
-/*
- * Traditional implementation of leap year evaluation.
- */
-static bool is_leap(long year)
-{
-	return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
-}
+#include <linux/rtc.h>
 
 /*
  * Gets the last day of a month.
@@ -17,7 +10,7 @@ static bool is_leap(long year)
 static int last_day_of_month(long year, int month)
 {
 	if (month == 2)
-		return 28 + is_leap(year);
+		return 28 + is_leap_year(year);
 	if (month == 4 || month == 6 || month == 9 || month == 11)
 		return 30;
 	return 31;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-31 13:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23  8:09 [PATCH] kunit: time: use is_leap_year() helper Jinjie Ruan
2026-01-26 15:22 ` [tip: timers/core] time/kunit: Use " tip-bot2 for Jinjie Ruan
2026-01-30 15:11 ` [PATCH] kunit: time: use " Mark Brown
2026-01-30 19:39   ` Mark Brown
2026-01-30 21:13     ` Thomas Gleixner
2026-01-31 13:31       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox