version 1.11, 2001/06/05 21:27:16 |
version 1.13, 2001/09/27 18:19:20 |
|
|
* with \t, is shown along with the matched line. |
* with \t, is shown along with the matched line. |
*/ |
*/ |
struct match * |
struct match * |
isnow(endp) |
isnow(endp, bodun) |
char *endp; |
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; |
|
|
if (!(v1 = getfield(endp, &endp, &flags))) |
if (!(v1 = getfield(endp, &endp, &flags))) |
return (NULL); |
return (NULL); |
|
|
|
/* adjust bodun rate */ |
|
if (bodun && !bodun_always) |
|
bodun = !(arc4random() % 3); |
|
|
/* Easter or Easter depending days */ |
/* Easter or Easter depending days */ |
if (flags & F_SPECIAL) |
if (flags & F_SPECIAL) |
vwd = v1; |
vwd = v1; |
|
|
if ((v2 += isleap(tp->tm_year + TM_YEAR_BASE) ? 366 : 365) |
if ((v2 += isleap(tp->tm_year + TM_YEAR_BASE) ? 366 : 365) |
<= v1) |
<= v1) |
tmtmp.tm_year++; |
tmtmp.tm_year++; |
else |
else if(!bodun || (day - tp->tm_yday) != -1) |
return(NULL); |
return(NULL); |
} |
} |
if ((tmp = malloc(sizeof(struct match))) == NULL) |
if ((tmp = malloc(sizeof(struct match))) == NULL) |
err(1, NULL); |
err(1, NULL); |
tmp->when = f_time + v2 * SECSPERDAY; |
|
|
if (bodun && (day - tp->tm_yday) == -1) { |
|
tmp->when = f_time - 1 * SECSPERDAY; |
|
tmtmp.tm_mday++; |
|
tmp->bodun = 1; |
|
} else { |
|
tmp->when = f_time + v2 * SECSPERDAY; |
|
tmp->bodun = 0; |
|
} |
|
|
(void)mktime(&tmtmp); |
(void)mktime(&tmtmp); |
if (strftime(tmp->print_date, |
if (strftime(tmp->print_date, |
sizeof(tmp->print_date), |
sizeof(tmp->print_date), |
/* "%a %b %d", &tm); Skip weekdays */ |
/* "%a %b %d", &tm); Skip weekdays */ |
"%b %d", &tmtmp) == 0) |
"%b %d", &tmtmp) == 0) |
tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; |
tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; |
|
|
tmp->var = varp; |
tmp->var = varp; |
tmp->next = NULL; |
tmp->next = NULL; |
return(tmp); |
return(tmp); |
|
|
warnx("time out of range: %s", endp); |
warnx("time out of range: %s", endp); |
else { |
else { |
tdiff = difftime(ttmp, f_time)/ SECSPERDAY; |
tdiff = difftime(ttmp, f_time)/ SECSPERDAY; |
if (tdiff <= offset + f_dayAfter) { |
if (tdiff <= offset + f_dayAfter || |
if (tdiff >= 0) { |
(bodun && tdiff == -1)) { |
|
if (tdiff >= 0 || |
|
(bodun && tdiff == -1)) { |
if ((tmp = malloc(sizeof(struct match))) == NULL) |
if ((tmp = malloc(sizeof(struct match))) == NULL) |
err(1, NULL); |
err(1, NULL); |
tmp->when = ttmp; |
tmp->when = ttmp; |
|
|
/* "%a %b %d", &tm); Skip weekdays */ |
/* "%a %b %d", &tm); Skip weekdays */ |
"%b %d", &tmtmp) == 0) |
"%b %d", &tmtmp) == 0) |
tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; |
tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; |
|
tmp->bodun = bodun && tdiff == -1; |
tmp->var = varp; |
tmp->var = varp; |
tmp->next = NULL; |
tmp->next = NULL; |
if (tmp2) |
if (tmp2) |