00001
00002
00003
00004
00005
00006 #include <time.h>
00007 #include <limits.h>
00008 #include "loc_time.h"
00009
00010 struct tm *
00011 gmtime(register const time_t *timer)
00012 {
00013 static struct tm br_time;
00014 register struct tm *timep = &br_time;
00015 time_t time = *timer;
00016 register unsigned long dayclock, dayno;
00017 int year = EPOCH_YR;
00018
00019 dayclock = (unsigned long)time % SECS_DAY;
00020 dayno = (unsigned long)time / SECS_DAY;
00021
00022 timep->tm_sec = dayclock % 60;
00023 timep->tm_min = (dayclock % 3600) / 60;
00024 timep->tm_hour = dayclock / 3600;
00025 timep->tm_wday = (dayno + 4) % 7;
00026 while (dayno >= YEARSIZE(year)) {
00027 dayno -= YEARSIZE(year);
00028 year++;
00029 }
00030 timep->tm_year = year - YEAR0;
00031 timep->tm_yday = dayno;
00032 timep->tm_mon = 0;
00033 while (dayno >= _ytab[LEAPYEAR(year)][timep->tm_mon]) {
00034 dayno -= _ytab[LEAPYEAR(year)][timep->tm_mon];
00035 timep->tm_mon++;
00036 }
00037 timep->tm_mday = dayno + 1;
00038 timep->tm_isdst = 0;
00039
00040 return timep;
00041 }