5 #define HOUR (60*MINUTE)
9 /* interestingly, we assume leap-years */
10 static int month
[12] = {
17 DAY
*(31+28+31+30+31+30),
18 DAY
*(31+28+31+30+31+30+31),
19 DAY
*(31+28+31+30+31+30+31+31),
20 DAY
*(31+28+31+30+31+30+31+31+30),
21 DAY
*(31+28+31+30+31+30+31+31+30+31),
22 DAY
*(31+28+31+30+31+30+31+31+30+31+30)
25 long kernel_mktime(struct tm
* tm
)
31 year
= tm
->tm_year
- 1;
32 leap
= ((tm
->tm_year
% 4)?0:((tm
->tm_year
% 100)?0:1));
34 res
= YEAR
*year
+ DAY
*(year
/4);
35 res
+= month
[tm
->tm_mon
];
37 if (tm
->tm_mon
>1 && leap
)
39 res
+= DAY
*(tm
->tm_mday
-1);
40 res
+= HOUR
*tm
->tm_hour
;
41 res
+= MINUTE
*tm
->tm_min
;