version 1.1, 1996/12/05 06:04:39 |
version 1.2, 1997/08/26 23:37:21 |
|
|
setnnames(); |
setnnames(); |
} |
} |
|
|
/* convert Day[/Month][/Year] into unix time (since 1970) |
/* convert [Year][Month]Day into unix time (since 1970) |
* Day: two digits, Month: two digits, Year: digits |
* Year: two or four digits, Month: two digits, Day: two digits |
*/ |
*/ |
time_t Mktime (date) |
time_t Mktime (date) |
char *date; |
char *date; |
{ |
{ |
time_t t; |
time_t t; |
|
char save; |
int len; |
int len; |
struct tm tm; |
struct tm tm; |
|
|
|
|
tp = localtime(&t); |
tp = localtime(&t); |
|
|
len = strlen(date); |
len = strlen(date); |
|
if (len < 2) |
|
return((time_t)-1); |
tm.tm_sec = 0; |
tm.tm_sec = 0; |
tm.tm_min = 0; |
tm.tm_min = 0; |
tm.tm_hour = 0; |
tm.tm_hour = 0; |
|
|
tm.tm_mon = tp->tm_mon; |
tm.tm_mon = tp->tm_mon; |
tm.tm_year = tp->tm_year; |
tm.tm_year = tp->tm_year; |
|
|
|
/* Day */ |
|
tm.tm_mday = atoi(date + len - 2); |
|
|
/* day */ |
/* Month */ |
*(date+2) = NULL; |
|
tm.tm_mday = atoi(date); |
|
|
|
/* month */ |
|
if (len >= 4) { |
if (len >= 4) { |
*(date+5) = NULL; |
*(date + len - 2) = '\0'; |
tm.tm_mon = atoi(date+3) - 1; |
tm.tm_mon = atoi(date + len - 4) - 1; |
} |
} |
|
|
/* Year */ |
/* Year */ |
if (len >= 7) { |
if (len >= 7) { |
tm.tm_year = atoi(date+6); |
*(date + len - 4) = '\0'; |
|
tm.tm_year = atoi(date); |
|
|
/* tm_year up 1900 ... */ |
/* tm_year up 1900 ... */ |
if (tm.tm_year > 1900) |
if (tm.tm_year > 1900) |