version 1.15, 2003/06/03 02:56:06 |
version 1.16, 2004/12/10 15:00:27 |
|
|
struct tm *tp; |
struct tm *tp; |
int *cumdays, offset; |
int *cumdays, offset; |
char dayname[10]; |
char dayname[10]; |
|
enum calendars calendar; |
|
u_long julian; |
|
|
|
|
/* 1-based month, 0-based days, cumulative */ |
/* 1-based month, 0-based days, cumulative */ |
|
|
return(mktime(&tm)); |
return(mktime(&tm)); |
} |
} |
|
|
|
void |
|
adjust_calendar(int *day, int *month) |
|
{ |
|
switch (calendar) { |
|
case GREGORIAN: |
|
break; |
|
|
|
case JULIAN: |
|
*day += julian; |
|
if (*day > (cumdays[*month + 1] - cumdays[*month])) { |
|
*day -= (cumdays[*month + 1] - cumdays[*month]); |
|
if (++*month > 12) |
|
*month = 1; |
|
} |
|
break; |
|
case LUNAR: |
|
break; |
|
} |
|
} |
|
|
/* |
/* |
* Possible date formats include any combination of: |
* Possible date formats include any combination of: |
* 3-charmonth (January, Jan, Jan) |
* 3-charmonth (January, Jan, Jan) |
|
|
if (month == -1) { |
if (month == -1) { |
month = tp->tm_mon + 1; |
month = tp->tm_mon + 1; |
interval = MONTHLY; |
interval = MONTHLY; |
} |
} else if (calendar) |
|
adjust_calendar(&day, &month); |
if ((month > 12) || (month < 1)) |
if ((month > 12) || (month < 1)) |
return (NULL); |
return (NULL); |
} |
} |
|
|
day = 1; |
day = 1; |
/* If a weekday was spelled out without an ordering, |
/* If a weekday was spelled out without an ordering, |
* assume the first of that day in the month */ |
* assume the first of that day in the month */ |
if ((flags & F_ISDAY) && (day >= 1) && (day <=7)) |
if ((flags & F_ISDAY)) { |
day += 10; |
if ((day >= 1) && (day <=7)) |
|
day += 10; |
|
} else if (calendar) |
|
adjust_calendar(&day, &month); |
} |
} |
|
|
/* Hm ... */ |
/* Hm ... */ |
|
|
if (month == -1) { |
if (month == -1) { |
month = tp->tm_mon + 1; |
month = tp->tm_mon + 1; |
interval = MONTHLY; |
interval = MONTHLY; |
} |
} else if (calendar) |
|
adjust_calendar(&day, &month); |
} |
} |
|
|
/* {Month} {Weekday,Day} ... */ |
/* {Month} {Weekday,Day} ... */ |
|
|
month = v1; |
month = v1; |
/* if no recognizable day, assume the first */ |
/* if no recognizable day, assume the first */ |
day = v2 ? v2 : 1; |
day = v2 ? v2 : 1; |
if ((flags & F_ISDAY) && (day >= 1) && (day <= 7)) |
if ((flags & F_ISDAY)) { |
day += 10; |
if ((day >= 1) && (day <= 7)) |
|
day += 10; |
|
} else |
|
adjust_calendar(&day, &month); |
} |
} |
} |
} |
|
|
|
|
tmp->next = NULL; |
tmp->next = NULL; |
return(tmp); |
return(tmp); |
} |
} |
} |
} else { |
else { |
|
varp = 1; |
varp = 1; |
/* Set up v1 to the event number and ... */ |
/* Set up v1 to the event number and ... */ |
v1 = vwd % (NUMEV + 1) - 1; |
v1 = vwd % (NUMEV + 1) - 1; |