at_wini also needs a pci_reserve() for the pci compatability device, if
[minix3.git] / lib / ansi / localtime.c
blob36d22546a0303de7b8f9d723294e872a8ae1a518
1 /*
2 * localtime - convert a calendar time into broken down time
3 */
4 /* $Header$ */
6 #include <time.h>
7 #include "loc_time.h"
9 /* We must be careful, since an int can't represent all the seconds in a day.
10 * Hence the adjustment of minutes when adding timezone and dst information.
11 * This assumes that both must be expressable in multiples of a minute.
12 * Furthermore, it is assumed that both fit into an integer when expressed as
13 * minutes (this is about 22 days, so this should not cause any problems).
15 struct tm *
16 localtime(const time_t *timer)
18 struct tm *timep;
19 unsigned dst;
21 _tzset();
22 timep = gmtime(timer); /* tm->tm_isdst == 0 */
23 timep->tm_min -= _timezone / 60;
24 timep->tm_sec -= _timezone % 60;
25 mktime(timep);
27 dst = _dstget(timep);
28 if (dst) {
29 timep->tm_min += dst / 60;
30 timep->tm_sec += dst % 60;
31 mktime(timep);
33 return timep;