Skip to content

Instantly share code, notes, and snippets.

@advorak
Forked from anonymous/Calendar
Created May 21, 2012 06:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save advorak/2760835 to your computer and use it in GitHub Desktop.
Calendar
<cfoutput>
<table border="1" width="100%" height="100%">
<tr>
<cfloop index="x" from="1" to="7">
<th>#dayOfWeekAsString(x)#</th>
</cfloop>
</tr>
</cfoutput>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset dow = dayofWeek(firstOfTheMonth)>
<cfset pad = dow - 1>
<tr>
<cfif pad gt 0>
<cfoutput><td colspan="#pad#">&nbsp;</td></cfoutput>
</cfif>
<cfset days = daysInMonth(now())>
<cfset counter = pad + 1>
<cfloop index="x" from="1" to="#days#">
<cfif x is day(now())>
<cfoutput><td bgcolor="yellow"></cfoutput>
<cfelse>
<td>
</cfif>
<cfoutput>
#x#</td>
</cfoutput>
<cfset counter = counter + 1>
<cfif counter is 8>
<cfoutput></tr></cfoutput>
<cfif x lt days>
<cfset counter = 1>
<tr>
</cfif>
</cfif>
</cfloop>
<cfif counter is not 8>
<cfset endPad = 8 - counter>
<cfoutput>
<td colspan="#endPad#">&nbsp;</td>
</cfoutput>
</cfif>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment