RE: Recurring Events ? ex. 3rd thursday

2006-02-14 Thread Emmet McGovern
Thank You Charlie!  That works perfect.

-e

-Original Message-
From: Charlie Griefer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 14, 2006 12:10 PM
To: CF-Talk
Subject: Re: Recurring Events ? ex. 3rd thursday

not thoroughly tested...


function getEveryNthDay(dow,nth,yy) {
/**
 * returns an array of dates containing every (nth) day of
week for
a given year
 *
 * @param dow   the day of the week to return
(integer...sunday = 1 /
saturday = 7)
 * @param nth   every (nth) day of the week (integer...1-5
are valid
argument values)
 * @param yythe year to check
 *
 * @return an array of dates.
 * @author Charlie Griefer ([EMAIL PROTECTED])
 * @version 1.0, February 14, 2006
 */
var containerArray = arrayNew(1);

var mm  = "";
var dd  = "";
var startDate   = "";
var dateFound   = 0;

if (val(dow) LT 1 OR val(dow) GT 7) {
return false;
}

for (mm=1; mm LTE 12; mm=mm+1) {
dateFound = 0;
for (dd=1; dd LTE daysInMonth(createDate(yy, mm,
1)); dd=dd+1) {
startDate = createDate(yy, mm, dd);
if (dayOfWeek(startDate) EQ dow) {
dateFound = dateFound + 1;
if (dateFound EQ nth) {
arrayAppend(containerArray,
startDate);
}
}
}
}

return containerArray;
}


3rd friday of each month (tuesday = 6):





On 2/14/06, Emmet McGovern <[EMAIL PROTECTED]> wrote:
> I can't seem to wrap my head around this.   Does anyone know how you loop
> through every third Thursday of the month in a year or every second
Tuesday
> and so on?
>
> Emmet
>
>
>
> 



~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232223
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recurring Events ? ex. 3rd thursday

2006-02-14 Thread Charlie Griefer
ermm..

3rd friday of each month (tuesday = 6):

shoulda oughtta have read:

3rd friday of each month (friday = 6):

:)

--
Charlie Griefer


"...All the world shall be your enemy, Prince with a Thousand Enemies,
and whenever they catch you, they will kill you. But first they must catch
you, digger, listener, runner, prince with a swift warning.
Be cunning and full of tricks and your people shall never be destroyed."

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232210
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Recurring Events ? ex. 3rd thursday

2006-02-14 Thread Charlie Griefer
not thoroughly tested...


function getEveryNthDay(dow,nth,yy) {
/**
 * returns an array of dates containing every (nth) day of week 
for
a given year
 *
 * @param dow   the day of the week to return (integer...sunday 
= 1 /
saturday = 7)
 * @param nth   every (nth) day of the week (integer...1-5 are 
valid
argument values)
 * @param yythe year to check
 *
 * @return an array of dates.
 * @author Charlie Griefer ([EMAIL PROTECTED])
 * @version 1.0, February 14, 2006
 */
var containerArray = arrayNew(1);

var mm  = "";
var dd  = "";
var startDate   = "";
var dateFound   = 0;

if (val(dow) LT 1 OR val(dow) GT 7) {
return false;
}

for (mm=1; mm LTE 12; mm=mm+1) {
dateFound = 0;
for (dd=1; dd LTE daysInMonth(createDate(yy, mm, 1)); 
dd=dd+1) {
startDate = createDate(yy, mm, dd);
if (dayOfWeek(startDate) EQ dow) {
dateFound = dateFound + 1;
if (dateFound EQ nth) {
arrayAppend(containerArray, 
startDate);
}
}
}
}

return containerArray;
}


3rd friday of each month (tuesday = 6):





On 2/14/06, Emmet McGovern <[EMAIL PROTECTED]> wrote:
> I can't seem to wrap my head around this.   Does anyone know how you loop
> through every third Thursday of the month in a year or every second Tuesday
> and so on?
>
> Emmet
>
>
>
> 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232206
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Recurring Events ? ex. 3rd thursday

2006-02-14 Thread Russ
There are some functions on cflib that let you get X weekday of the month...


> -Original Message-
> From: Emmet McGovern [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 14, 2006 11:17 AM
> To: CF-Talk
> Subject: Recurring Events ? ex. 3rd thursday
> 
> I can't seem to wrap my head around this.   Does anyone know how you loop
> through every third Thursday of the month in a year or every second
> Tuesday
> and so on?
> 
> Emmet
> 
> 
> 
> 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232203
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54