All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: Modify leap year test for more simpler way
@ 2013-02-06 11:22 Jonghwa Lee
  2013-02-06 11:42 ` Venu Byravarasu
  0 siblings, 1 reply; 7+ messages in thread
From: Jonghwa Lee @ 2013-02-06 11:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: a.zummo, Andrew Morton, rtc-linux, Jonghwa Lee

Leap year which is multiple of 4, just needed 2 LSB for verifying.
A year with zero for all thease two bits means that it is leap year.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
---
 include/linux/rtc.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 9531845..d662b8d 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -181,7 +181,7 @@ void rtc_timer_do_work(struct work_struct *work);
 
 static inline bool is_leap_year(unsigned int year)
 {
-	return (!(year % 4) && (year % 100)) || !(year % 400);
+	return !(year & 0x3);
 }
 
 #ifdef CONFIG_RTC_HCTOSYS_DEVICE
-- 
1.7.9.5


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

end of thread, other threads:[~2013-02-07  1:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06 11:22 [PATCH] rtc: Modify leap year test for more simpler way Jonghwa Lee
2013-02-06 11:42 ` Venu Byravarasu
2013-02-06 12:43   ` jonghwa3.lee
2013-02-06 12:53     ` jonghwa3.lee
2013-02-06 13:00     ` Haojian Zhuang
2013-02-06 18:11       ` Stephen Warren
2013-02-07  1:15         ` jonghwa3.lee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.