#include #include #include #include /* This is not a full implementation of mktime, it just barely satisfies what I need. */ time_t mymktime(struct tm *t) { int mon,year,day,hour,min,sec; mon = t->tm_mon+1; year = t->tm_year+1900; day = t->tm_mday; hour = t->tm_hour; min = t->tm_min; sec = t->tm_sec; if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ mon += 12; /* Puts Feb last since it has leap day */ year -= 1; } return ((( (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + year*365 - 719499 )*24 + hour /* now have hours */ )*60 + min /* now have minutes */ )*60 + sec; /* finally seconds */ } #ifdef TESTING_MKTIME main() { static struct tm t; t.tm_year = 94; t.tm_mon = 1; t.tm_mday = 1; t.tm_hour = 2; t.tm_min = 3; t.tm_sec = 4; printf("Date convert %d \n",my_mktime(&t)); printf("Date convert %d \n",mktime(&t)); } #endif