I recently wrote a calendar application that allows
Day, Week, Month, Year with events scheduled per day.

The trickiest part was setting up the months to look
like an actual month. That is to start your day
in which table column. Like if your month starts
on a Friday then the first has to show up on a
Friday.

There is a really easy way to achieve this, and
after I figured out this part it was a cake walk:)

It is the DayOfWeek function :)

So say your date 10.1.00 which happens to fall
on saturday, so this would return 1 which means
your offset for that day is one, meaning it
belongs in the first column.

try it with 11.1.00 which falls on a Wednesday

DayOfWeek returns 4 for this date meaning your
day belongs in the 4th column. :)

This avoids doing any complex logic to figure
this out.

Basically you can display a calendar month with
only one loop with x iterations (x being
the number of days in the month) which makes it
rather effecient ( I then had one more inner
loop to handle checking for events )

So I was pleased with the speed of the calendar
I have seen some that were terribly slow :) Here
is a little snippet so you guys dont maul me :P

Also with this logic you can figure out how
many days the end will be by figuring out the day
of the week for the last day in the month.

That is pretty much all of the tricky stuff to
doing a calendar, year views are easy since you
already have a nice tight way to display months.

So as Ed said its eeeeeeeeeeeeeeeeeeasy :)

Ive written equivalent stuff in C and the math
can drive you insane, really really CF has some
of the nicest date functions around.


Jeremy Allen
[EMAIL PROTECTED]


-----Original Message-----
From: Ed Toon [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 06, 2000 11:05 AM
To: CF-Talk
Subject: RE: dynamically filling a calendar


The CF date functions make this kind of stuff really, really easy.

I made a calendar app a few months ago to pass the time while waiting for a
contract with eCal to be signed. It ended up being far better than eCal's
app, but we didn't really need a calendar in the end. If I remember, the
most difficult thing was figuring out how to deal with months that start on
Friday, months with 29 days, etc... which wasn't really too bad. ;)

Some useful functions:

CreateDate(year, month, day)
FirstDayOfMonth(date)
DaysInMonth(date)
DateAdd(datepart, number, date)

Ed

----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to