Skip to content

Instantly share code, notes, and snippets.

@howellcc
Created October 19, 2015 14:00
Show Gist options
  • Save howellcc/799d000c6de072778025 to your computer and use it in GitHub Desktop.
Save howellcc/799d000c6de072778025 to your computer and use it in GitHub Desktop.
Displaying Mura Event Dates
<cffunction name="dspEventDate" output="true">
<cfargument type="any" name="contentBean" >
<cfset var l = {} />
<cfset l.displayStart = contentBean.getValue("displayStart") />
<cfset l.displayStop = contentBean.getValue("displayStop") />
<cfset l.displayInterval = contentBean.getValue("displayInterval") />
<cfset l.returnVar = "" />
<cfoutput>
<cfswitch expression="#l.displayInterval#" >
<cfcase value="Daily">
<!--- is it 1 day or every day --->
<cfif len(l.displayStop) eq 0 OR dateFormat(l.displayStart,'yyyymmdd') eq dateFormat(l.displayStop,"yyyymmdd") >
<!--- 1 Day --->
<p><strong>#DateFormat(l.displayStart, "mmmm d, yyyy")#</strong></p>
<cfelse>
<!--- Every day --->
<p><strong>Daily from #DateFormat(l.displayStart, "mmmm d, yyyy")# through #DateFormat(l.displayStop, "mmmm d, yyyy")#</strong></p>
</cfif>
</cfcase>
<cfcase value="Weekly,Bi-Weekly" delimiters=",">
<p><strong>#l.displayInterval# on #dayOfWeekAsString(dayOfWeek(l.displayStart))#s</strong></p>
</cfcase>
<cfcase value="Monthly">
<cfset l.suffix = stndrd(day(l.displayStart))>
<p><strong>#l.displayInterval# on the #day(l.displayStart)##l.suffix# of the month</strong></p>
</cfcase>
<cfcase value="WeekDays">
<p><strong>Week Days</strong></p>
</cfcase>
<cfcase value="WeekEnds">
<p><strong>Week Ends</strong></p>
</cfcase>
<cfcase value="Week1,Week2,Week3,Week4" delimiters=",">
<cfset l.suffix = stndrd(right(l.displayInterval,1))>
<p><strong>Monthly on the #right(l.displayInterval,1)##l.suffix# #dayOfWeekAsString(dayOfWeek(l.displayStart))# of the month</strong></p>
</cfcase>
<cfcase value="WeekLast">
<cfset l.suffix = stndrd(right(l.displayInterval,1))>
<p><strong>Monthly on the last #dayOfWeekAsString(dayOfWeek(l.displayStart))# of the month</strong></p>
</cfcase>
<cfcase value="Yearly">
<p><strong>Yearly on #dateFormat(l.displayStart,"mmm d")#</strong></p>
</cfcase>
</cfswitch>
<p>
<strong>#LSTimeFormat(l.displayStart, 'short')#
<cfif len(l.displayStop) AND LSTimeFormat(l.displayStop, 'short') NEQ LSTimeFormat(l.displayStart, 'short')>
- #LSTimeFormat(l.displayStop, 'short')#
</cfif>
</strong>
</p>
</cfoutput>
</cffunction>
<cffunction name="stndrd" >
<cfargument name="dayOfMonth" type="numeric" required="true">
<cfset var num = dayOfMonth mod 10>
<cfswitch expression="#num#">
<cfcase value="0,4,5,6,7,8,9" delimiters=",">
<cfreturn "th">
</cfcase>
<cfcase value="1" >
<cfreturn "st">
</cfcase>
<cfcase value="2" >
<cfreturn "nd">
</cfcase>
<cfcase value="3" >
<cfreturn "rd">
</cfcase>
</cfswitch>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment