version 1.19, 2005/08/09 12:32:58 |
version 1.20, 2005/11/16 16:45:11 |
|
|
static struct fixs nmonths[13]; /* short national month names */ |
static struct fixs nmonths[13]; /* short national month names */ |
|
|
|
|
void setnnames(void) |
void |
|
setnnames(void) |
{ |
{ |
char buf[80]; |
char buf[80]; |
int i, l; |
int i, l; |
|
|
} |
} |
|
|
void |
void |
settime(now) |
settime(time_t *now) |
time_t *now; |
|
{ |
{ |
tp = localtime(now); |
tp = localtime(now); |
tp->tm_sec = 0; |
tp->tm_sec = 0; |
|
|
/* convert [Year][Month]Day into unix time (since 1970) |
/* convert [Year][Month]Day into unix time (since 1970) |
* Year: two or four digits, Month: two digits, Day: two digits |
* Year: two or four digits, Month: two digits, Day: two digits |
*/ |
*/ |
time_t Mktime (date) |
time_t |
char *date; |
Mktime(char *date) |
{ |
{ |
time_t t; |
time_t t; |
int len; |
int len; |
struct tm tm; |
struct tm tm; |
|
|
(void)time(&t); |
(void)time(&t); |
tp = localtime(&t); |
tp = localtime(&t); |
|
|
len = strlen(date); |
len = strlen(date); |
if (len < 2) |
if (len < 2) |
return((time_t)-1); |
return((time_t)-1); |
tm.tm_sec = 0; |
tm.tm_sec = 0; |
tm.tm_min = 0; |
tm.tm_min = 0; |
/* Avoid getting caught by a timezone shift; set time to noon */ |
/* Avoid getting caught by a timezone shift; set time to noon */ |
tm.tm_isdst = 0; |
tm.tm_isdst = 0; |
tm.tm_hour = 12; |
tm.tm_hour = 12; |
tm.tm_wday = 0; |
tm.tm_wday = 0; |
tm.tm_mday = tp->tm_mday; |
tm.tm_mday = tp->tm_mday; |
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 */ |
/* Day */ |
tm.tm_mday = atoi(date + len - 2); |
tm.tm_mday = atoi(date + len - 2); |
|
|
/* Month */ |
/* Month */ |
if (len >= 4) { |
if (len >= 4) { |
*(date + len - 2) = '\0'; |
*(date + len - 2) = '\0'; |
tm.tm_mon = atoi(date + len - 4) - 1; |
tm.tm_mon = atoi(date + len - 4) - 1; |
} |
} |
|
|
/* Year */ |
/* Year */ |
if (len >= 6) { |
if (len >= 6) { |
*(date + len - 4) = '\0'; |
*(date + len - 4) = '\0'; |
tm.tm_year = atoi(date); |
tm.tm_year = atoi(date); |
|
|
/* tm_year up TM_YEAR_BASE ... */ |
/* tm_year up TM_YEAR_BASE ... */ |
if (tm.tm_year < 69) /* Y2K */ |
if (tm.tm_year < 69) /* Y2K */ |
tm.tm_year += 2000 - TM_YEAR_BASE; |
tm.tm_year += 2000 - TM_YEAR_BASE; |
else if (tm.tm_year < 100) |
else if (tm.tm_year < 100) |
tm.tm_year += 1900 - TM_YEAR_BASE; |
tm.tm_year += 1900 - TM_YEAR_BASE; |
else if (tm.tm_year > TM_YEAR_BASE) |
else if (tm.tm_year > TM_YEAR_BASE) |
tm.tm_year -= TM_YEAR_BASE; |
tm.tm_year -= TM_YEAR_BASE; |
} |
} |
|
|
#if DEBUG |
#if DEBUG |
printf("Mktime: %d %d %d %s\n", (int)mktime(&tm), (int)t, len, |
printf("Mktime: %d %d %d %s\n", (int)mktime(&tm), (int)t, len, |
asctime(&tm)); |
asctime(&tm)); |
#endif |
#endif |
return(mktime(&tm)); |
return(mktime(&tm)); |
} |
} |
|
|
void |
void |
|
|
* with \t, is shown along with the matched line. |
* with \t, is shown along with the matched line. |
*/ |
*/ |
struct match * |
struct match * |
isnow(endp, bodun) |
isnow(char *endp, int bodun) |
char *endp; |
|
int bodun; |
|
{ |
{ |
int day = 0, flags = 0, month = 0, v1, v2, i; |
int day = 0, flags = 0, month = 0, v1, v2, i; |
int monthp, dayp, varp = 0; |
int monthp, dayp, varp = 0; |
|
|
|
|
|
|
int |
int |
getmonth(s) |
getmonth(char *s) |
char *s; |
|
{ |
{ |
char **p; |
char **p; |
struct fixs *n; |
struct fixs *n; |
|
|
|
|
|
|
int |
int |
getday(s) |
getday(char *s) |
char *s; |
|
{ |
{ |
char **p; |
char **p; |
struct fixs *n; |
struct fixs *n; |
|
|
* ... etc ... |
* ... etc ... |
*/ |
*/ |
int |
int |
getdayvar(s) |
getdayvar(char *s) |
char *s; |
|
{ |
{ |
int offset; |
int offset; |
|
|
|
|
|
|
|
|
int |
int |
foy(year) |
foy(int year) |
int year; |
|
{ |
{ |
/* 0-6; what weekday Jan 1 is */ |
/* 0-6; what weekday Jan 1 is */ |
year--; |
year--; |
|
|
|
|
|
|
void |
void |
variable_weekday(day, month, year) |
variable_weekday(int *day, int month, int year) |
int *day, month, year; |
|
{ |
{ |
int v1, v2; |
int v1, v2; |
int *cumdays; |
int *cumdays; |