5 #define isleap(y) (!((y) % 4) && ((y) % 100) || !((y) % 400))
6 #define SPD (24 * 60 * 60)
14 timezone
= tz
.tz_minuteswest
* 60;
17 static void tp2tm(struct tm
*tm
, time_t t
)
19 static int dpm
[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
23 tm
->tm_sec
= rem
% 60;
25 tm
->tm_min
= rem
% 60;
26 tm
->tm_hour
= rem
/ 60;
27 tm
->tm_wday
= (4 + days
) % 7;
29 /* calculating yday and year */
30 for (i
= 1970; days
>= 365 + isleap(i
); i
++)
31 days
-= 365 + isleap(i
);
32 tm
->tm_year
= i
- 1900;
35 /* calculating mday and mon */
37 if (isleap(i
) && days
== 59)
39 if (isleap(i
) && days
>= 59)
41 for (i
= 0; i
< 11 && days
>= dpm
[i
]; i
++)
47 struct tm
*localtime(long *t
)
51 tp2tm(&tm
, *t
- timezone
);
55 struct tm
*gmtime(long *t
)