Skip to content

Instantly share code, notes, and snippets.

@vikaskanani
Forked from isummation/TimeSlot.cfm
Created October 18, 2013 04:13
Show Gist options
  • Save vikaskanani/7036400 to your computer and use it in GitHub Desktop.
Save vikaskanani/7036400 to your computer and use it in GitHub Desktop.
<cfdump var="#TimeSlot(Minutslot = 15)#" />
<cffunction name="TimeSlot" output="false" access="public" returntype="any">
<cfargument name="Minutslot" type="numeric" required="true">
<cfif 1440 MOD arguments.Minutslot NEQ 0>
<cfthrow type="user" message="Invalid Minute slot">
</cfif>
<cfset var i = 0>
<cfset var retArray = arrayNew(1)>
<cfset var TotalSlots = 1440 / arguments.Minutslot>
<cfset var StartTime = CreateDateTime(2013, 1, 1, 0, 0, 0)>
<cfset var EndTime = dateAdd("n", arguments.Minutslot, StartTime)>
<cfloop from="1" to="#TotalSlots#" index="i">
<cfset retArray[i] = timeFormat(StartTime, "hh:mm TT") & " To " & timeFormat(EndTime, "hh:mm TT")>
<cfset StartTime = EndTime>
<cfset EndTime = dateAdd("n", arguments.Minutslot, StartTime)>
</cfloop>
<cfreturn retArray>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment