A Small Calendar Utility For Reference

<div id="calendars">
 
	<!--- Loop over the months in the array. --->
	<cfloop
		index="intI"
		from="1"
		to="#ArrayLen( REQUEST.Months )#"
		step="1">
 
		<cfsilent>
 
			<!--- Get the pointer to the current date. --->
			<cfset dtThisMonth = REQUEST.Months[ intI ] />
 
			<!--- Get the starting day. --->
			<cfset dtStartDay = DateAdd(
				"d",
				-(DayOfWeek( dtThisMonth ) - 1),
				dtThisMonth
				) />
 
			<!--- Get the ending day. --->
			<cfset dtEndDay = (DateAdd( "m", 1, dtThisMonth ) - 1) />
 
			<!--- Stretch it to the end of the week. --->
			<cfset dtEndDay = DateAdd(
				"d",
				(7 - DayOfWeek( dtEndDay )),
				dtEndDay
				) />
 
 
			<!--- Get today's date. --->
			<cfset dtToday = Fix( REQUEST.Environment.DateTime.Now ) />
 
		</cfsilent>
 
		<table width="100%" border="0" cellspacing="2" cellpadding="0" class="calendarmonth">
		<thead>
			<tr>
				<td colspan="7">
					#MonthAsString( Month( dtThisMonth ) )# #Year( dtThisMonth )#
				</td>
			</tr>
		</thead>
		<tbody>
			<cfsilent>
				<cfsavecontent variable="strMonthCode">
 
					<tr>
 
						<!--- Loop over the days of the month. --->
						<cfloop index="dtDay" from="#dtStartDay#" to="#dtEndDay#" step="1">
 
							<td class="<cfif (dtDay EQ dtToday)>today<cfelseif (Month( dtDay ) EQ Month( dtThisMonth ))>thismonth<cfelse>othermonth</cfif>">
								#Day( dtDay )#
							</td>
 
							<cfif (
								(DayOfWeek( dtDay ) EQ 7) AND
								(dtDay NEQ dtEndDay)
								)>
								</tr>
								<tr>
							</cfif>
 
						</cfloop>
 
					</tr>
 
				</cfsavecontent>
			</cfsilent>
 
			<!--- Output code with as little white space as possible. --->
			#strMonthCode.ReplaceAll( ">\s+", ">" ).ReplaceAll( "\s+<", "<" )#
		</tbody>
		</table>
 
		<!--- Flush for user feedback. --->
		<cfflush />
 
	</cfloop>
 
</div>
 
<!--- Initialize the Calendar javascript. --->
<script type="text/javascript">
	InitCalendars();
</script>

For Cut-and-Paste