lkml.org 
[lkml]   [2013]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] rtc: Modify leap year test for more simpler way
Date
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


\
 
 \ /
  Last update: 2013-02-06 13:01    [W:0.053 / U:2.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site