This is roughly how I've done it in the past, from memory so excuse typos

When you record the events

you create a

seeddate ( eg the day the event starts )
interval ( weekly etc)

        <cfset norecurrance =   0>
        <cfset daily    =       1>
        <cfset weekly   =       2>
        <cfset monthly  =       4>
        <cfset yearly   =       8>

enddate (never or a date)

sample date

seeddate                enddate         recurs
-------------------------------------------
24/1/2002               never(null)             yearly
24/1/2002               never(null)             weekly
24/1/2002               24/3/2002               monthly
24/1/2002               never(null)             daily



Now when you go to select your records

week view (starting on date A ending on date B)
get events      where enddate > A and
        -       all daily events
        -       all weekly event
        -       monthly events where day(seeddate) between day(a) and Day(b)
        -       yearly  events where    month(seeddate) between month(a) and month(b) 
and
                                                day(seeddate) between day(a) and day(b)


Something like that

Now you have your recordset you need to build your recurring events . I've
done this a few different ways in the past, one way for example is to loop
over the records and expand out recurring events, creating a array for each
day (named in the format DD_MM_YYYY). This allows you to do some cool gui
stuff like having a band across days for events which continue daily from
date x -> date z ..It also means you only need to loop over the recordset
once, as opposed to once to each day you want to display [for each day, loop
over the records for event related to that day ] which would equal (31 *
amount of records) in a month view for example.

eg


<cfloop query>

        if interval not 0
                switch interval
                        daily
                                everyday events (easy) start at date

                        weekly, monthly, yearly
                                don't need to expand these - they just happen once in 
week view.


</cfloop>

(actually week is easy month is the most difficult)

so now you should have arrays named in the format DD_MM_YYYY for each day.

now display your week

<cfloop from=0 to=6  index=i>
        <cfset currentday = dateform(dateadd("d",a,i),"DD_MM_YYYY")>

        <cfif isdefined(currentday)>
                loop over array output the events (details stored in structures)
        <cfelse>
                no events
        </cfif>
</cfloop>


Thats one way.

Excuse the mess its off the top of my head. :-)

WG


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to