Uninitialized vector entry?
[minix3.git] / lib / ansi / gmtime.c
blob92c57e7d329110ee3b6b1b0df1508e52b18af339
1 /*
2 * gmtime - convert the calendar time into broken down time
3 */
4 /* $Header$ */
6 #include <time.h>
7 #include <limits.h>
8 #include "loc_time.h"
10 struct tm *
11 gmtime(register const time_t *timer)
13 static struct tm br_time;
14 register struct tm *timep = &br_time;
15 time_t time = *timer;
16 register unsigned long dayclock, dayno;
17 int year = EPOCH_YR;
19 dayclock = (unsigned long)time % SECS_DAY;
20 dayno = (unsigned long)time / SECS_DAY;
22 timep->tm_sec = dayclock % 60;
23 timep->tm_min = (dayclock % 3600) / 60;
24 timep->tm_hour = dayclock / 3600;
25 timep->tm_wday = (dayno + 4) % 7; /* day 0 was a thursday */
26 while (dayno >= YEARSIZE(year)) {
27 dayno -= YEARSIZE(year);
28 year++;
30 timep->tm_year = year - YEAR0;
31 timep->tm_yday = dayno;
32 timep->tm_mon = 0;
33 while (dayno >= _ytab[LEAPYEAR(year)][timep->tm_mon]) {
34 dayno -= _ytab[LEAPYEAR(year)][timep->tm_mon];
35 timep->tm_mon++;
37 timep->tm_mday = dayno + 1;
38 timep->tm_isdst = 0;
40 return timep;