2 * gmtime - convert the calendar time into broken down time
11 gmtime(register const time_t *timer
)
13 static struct tm br_time
;
14 register struct tm
*timep
= &br_time
;
16 register unsigned long dayclock
, dayno
;
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
);
30 timep
->tm_year
= year
- YEAR0
;
31 timep
->tm_yday
= dayno
;
33 while (dayno
>= _ytab
[LEAPYEAR(year
)][timep
->tm_mon
]) {
34 dayno
-= _ytab
[LEAPYEAR(year
)][timep
->tm_mon
];
37 timep
->tm_mday
= dayno
+ 1;