Kinky Calendar Leap Year Update

Posted March 4, 2008 at 3:37 PM

Tags: ColdFusion

Just a quick update - Peter Bell pointed out to me that my ColdFusion Kinky Calendar system was breaking on my site. I took a quick look, and indeed it was. Oh No! So, I threw on my ColdFusion ninja suit and jumped into action. The problem was a little mysterious to debug, but I finally narrowed it down to a leap year problem. The leap year itself was not causing the problem; the problem was that I had some code that looked like this:

 Launch code in new window » Download code as text file »

  • CreateDate(
  • (Year( start_date ) - 1),
  • Month( start_date ),
  • Day( start_date )
  • )

The problem here is that on February 29th of this year, the above code tried to create the 29th of last year. Of course, there was no February 29th of last year. This was an easy fix with some conditional logic.

Thanks Peter for bringing that to my attention. I have updated the Kinky Calendar project page with a new ZIP download.

Download Code Snippet ZIP File

Comments (8)  |  Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page



I'm Too Young For This!

Reader Comments

Can you tell us which file (line numbers) were changed so we can update our copies?

Posted by Sami Hoda on Mar 4, 2008 at 4:06 PM


Why not use DateAdd("yyyy",-1,start_date) ?

Posted by Steve Bryant on Mar 4, 2008 at 4:55 PM


Thanks! Sometimes February has only 28 days :-)

Posted by Werbeagentur on Mar 5, 2008 at 4:14 AM


@Sami,

It was the _functions.cfm file. It was several different lines for the month repeat and the year repeat. It's probably just easiest to download the ZIP and replace that function. Or, if you just want to swap out those case statements:

<!--- Repeat monthly. --->
<cfcase value="4">

and

<!--- Repeat yearly. --->
<cfcase value="5">

@Steve,

Hmmm, not sure. I think you might be on to something :) I love when I overlook the most obvious solution! Thanks Steve.

Posted by Ben Nadel on Mar 6, 2008 at 8:57 AM


@Steve,

Thanks for the tip. I updated the code with your DateAdd() suggestion. Seems to work like a charm.

Posted by Ben Nadel on Mar 6, 2008 at 10:10 AM


Thanks for the information ....

Posted by Werbeagentur Trendstrom on May 23, 2008 at 7:38 PM


I have not gotten this thing to work AT ALL.

There is a request variable somewhere that keeps giving me an error

Please post a working copy without the request.dsn.username VARIABLES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted by a non no mous on Aug 2, 2008 at 10:51 PM


I cannot post a version without that or none of it would work. I use that variable to pull data out of the database.

Posted by Ben Nadel on Aug 4, 2008 at 8:35 AM


Post Comment  |  Ask Ben


Home   |   Web Log   |   ColdFusion   |   Projects   |   Resume   |   Job Form   |   Search   |   Contact
Epicenter Consulting - Custom Software Solutions for Business Evolution HostMySite.com - The Leader In ColdFusion Hosting