version 1.1, 1996/12/05 06:04:39 |
version 1.4, 1998/03/30 06:59:26 |
|
|
|
|
for (i = 0; i < 7; i++) { |
for (i = 0; i < 7; i++) { |
tm.tm_wday = i; |
tm.tm_wday = i; |
strftime(buf, sizeof(buf), "%a", &tm); |
l = strftime(buf, sizeof(buf), "%a", &tm); |
for (l = strlen(buf); |
for (; l > 0 && isspace((int)buf[l - 1]); l--) |
l > 0 && isspace((int)buf[l - 1]); |
|
l--) |
|
; |
; |
buf[l] = '\0'; |
buf[l] = '\0'; |
if (ndays[i].name != NULL) |
if (ndays[i].name != NULL) |
|
|
errx(1, "cannot allocate memory"); |
errx(1, "cannot allocate memory"); |
ndays[i].len = strlen(buf); |
ndays[i].len = strlen(buf); |
|
|
strftime(buf, sizeof(buf), "%A", &tm); |
l = strftime(buf, sizeof(buf), "%A", &tm); |
for (l = strlen(buf); |
for (; l > 0 && isspace((int)buf[l - 1]); l--) |
l > 0 && isspace((int)buf[l - 1]); |
|
l--) |
|
; |
; |
buf[l] = '\0'; |
buf[l] = '\0'; |
if (fndays[i].name != NULL) |
if (fndays[i].name != NULL) |
|
|
|
|
for (i = 0; i < 12; i++) { |
for (i = 0; i < 12; i++) { |
tm.tm_mon = i; |
tm.tm_mon = i; |
strftime(buf, sizeof(buf), "%b", &tm); |
l = strftime(buf, sizeof(buf), "%b", &tm); |
for (l = strlen(buf); |
for (; l > 0 && isspace((int)buf[l - 1]); l--) |
l > 0 && isspace((int)buf[l - 1]); |
|
l--) |
|
; |
; |
buf[l] = '\0'; |
buf[l] = '\0'; |
if (nmonths[i].name != NULL) |
if (nmonths[i].name != NULL) |
|
|
errx(1, "cannot allocate memory"); |
errx(1, "cannot allocate memory"); |
nmonths[i].len = strlen(buf); |
nmonths[i].len = strlen(buf); |
|
|
strftime(buf, sizeof(buf), "%B", &tm); |
l = strftime(buf, sizeof(buf), "%B", &tm); |
for (l = strlen(buf); |
for (; l > 0 && isspace((int)buf[l - 1]); l--) |
l > 0 && isspace((int)buf[l - 1]); |
|
l--) |
|
; |
; |
buf[l] = '\0'; |
buf[l] = '\0'; |
if (fnmonths[i].name != NULL) |
if (fnmonths[i].name != NULL) |
|
|
time_t now; |
time_t now; |
{ |
{ |
tp = localtime(&now); |
tp = localtime(&now); |
if (isleap(tp->tm_year + 1900)) { |
if (isleap(tp->tm_year + TM_YEAR_BASE)) { |
yrdays = DAYSPERLYEAR; |
yrdays = DAYSPERLYEAR; |
cumdays = daytab[1]; |
cumdays = daytab[1]; |
} else { |
} else { |
|
|
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; |
|
|
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 TM_YEAR_BASE ... */ |
if (tm.tm_year > 1900) |
if (tm.tm_year < 70) |
tm.tm_year -= 1900; |
tm.tm_year += 2000 - TM_YEAR_BASE; |
|
else if (tm.tm_year < 100) |
|
tm.tm_year += 1900 - TM_YEAR_BASE; |
|
else if (tm.tm_year > TM_YEAR_BASE) |
|
tm.tm_year -= TM_YEAR_BASE; |
} |
} |
|
|
#if DEBUG |
#if DEBUG |