Thanks to all who helped figure some of this stuff out.
FWIW: Here's the calendar recurrence engine I built:
<cfscript>
// events may or may not have an end_date
if (Len(form.day_end)) {
end_date = "#form.month_end#/#form.day_end#/#form.year_end#"; }
else {
end_date = 'NULL';
}
// run through case statements for which kind of recurrance this is
switch (#form.RECURRENCE_TYPE#) {
// if onetime date entry, create a single element array
case "OneTime": {
mydate = ArrayNew(1);
mydate[1] = "#form.month#/#form.day#/#form.year#";
// get the final date of the array
finalDate=myDate[arrayLen(myDate)];
break;
}
case "Daily": {
calDays = 365;
interval = form.TIME_INTERVAL_daily;
numEvents = calDays \ interval;
myDate = ArrayNew(1);
myDate[1] = "#form.month#/#form.day#/#form.year#";
for(i=1; i LTE numEvents; i=i+1) {
arrayAppend(myDate, dateAdd('d', i *
interval,myDate[1]));
}
// get the final date of the array
finalDate=myDate[arrayLen(myDate)];
break;
}
case "Weekly": {
calDays = 365;
interval = form.TIME_INTERVAL_weekly;
numEvents = calDays \ interval;
numEvents = numEvents \ 7;
myDate = ArrayNew(1);
myDate[1] = "#form.month#/#form.day#/#form.year#";
for(i=1; i LTE numEvents; i=i+1) {
arrayAppend(myDate, dateAdd('d', (i * 7) *
interval,myDate[1]));
}
// get the final date of the array
finalDate=myDate[arrayLen(myDate)];
break;
}
case "Monthly": {
// calculate month recurrence
// udf can be found here: http://www.cflib.org/udf.cfm?ID=179
// udf modified to loop over 12 months past a change of year ...
calMonths = 12;
interval = form.TIME_INTERVAL_monthly;
numEvents = calMonths \ interval;
firstDate =
DayOfWeek('#form.month#/#form.day#/#form.year#');
/* check to see if pattern is specific date of each month,
* or Nth occurance of each day of the month */
if (form.PATTERN is "specificdate"){
// create array and seed with first date
myDate = ArrayNew(1);
myDate[1] = '#form.month#/#form.day#/#form.year#';
// loop over number of events for the year and create
date-specific array
for(i=1; i LTE numEvents; i=i+1) {
arrayAppend(myDate, dateAdd('m', i *
interval,myDate[1]));
}
}
Else {
// or use UDF to get the Nth day of the month for each month
for a year out
startDate = GetNthOccOfDayInMonth(form.EVERY_N, firstDate,
form.Month, form.Year);
// create array and seed with first date
myDate = ArrayNew(1);
myDate[1] = "#form.month#/#startDate#/#form.year#";
/* loop over UDF
* new month is each new month integer for 12 months through
the loop
* calcMonth contains the incremental integer so we can loop
over
* 12 months and recognize that we're dealing with a new
year
* when that happens, we calculate what month starting in
Jan. we're dealing with
*/
for(i=1; i LTE 12; i=i+1) {
newMonth=form.Month+i;
calcMonth=form.Month+i;
if (calcMonth GTE 13) {
useYear=form.Year+1;
newMonth=i-(12-form.month); }
else {useYear=form.Year;}
newDate =
GetNthOccOfDayInMonth(form.EVERY_N, firstDate, newMonth, useYear);
arrayAppend(myDate,
'#newMonth#/#newDate#/#useYear#');
}
}
// get the final date of the array
finalDate=myDate[arrayLen(myDate)];
break;
}
case "Yearly": {
break;
}
default: {
break;
}
}
</cfscript>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Owens
Internet Operations Coordinator
InsideVC.com/Ventura County Star
[EMAIL PROTECTED]
AIM: GoCatGo1956
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4