14 #include <linux/module.h>
15 #include <linux/rtc.h>
17 static const unsigned char rtc_days_in_month[] = {
18 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
21 static const unsigned short rtc_ydays[2][13] = {
23 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
25 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
28 #define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
35 return rtc_days_in_month[
month] + (is_leap_year(year) && month == 1);
44 return rtc_ydays[is_leap_year(year)][
month] + day-1;
57 time -= (
unsigned int) days * 86400;
62 year = 1970 + days / 365;
63 days -= (year - 1970) * 365
68 days += 365 + is_leap_year(year);
73 for (month = 0; month < 11; month++) {
99 || ((
unsigned)tm->
tm_mon) >= 12
102 || ((
unsigned)tm->
tm_hour) >= 24
103 || ((
unsigned)tm->
tm_min) >= 60
104 || ((
unsigned)tm->
tm_sec) >= 60)
129 return ktime_set(time, 0);
141 ts = ktime_to_timespec(kt);