I wrote and posted cf_Blackout in the devex years ago. Feed it a time
range and it blacks you out for that range.  Its smart enough to cross
midnight (i.e. it understands and 11pm to 6 am blackout).  Here's a
very slightly revised version of the posted code.

<!---
<CF_Blackout
        BOStart="05:30AM"
        BOStop="07:00AM">

The above tag call would return a blackout period beginning at 5:30:00
AM and ending at 7:00:59 AM
--->
        
<!---
set default response
--->
<cfset caller.BlackedOut="N">
<!---
Were the parameters for the  blackout period specified?
--->
<cfif isDefined ("attributes.BOStart") and IsDefined ("attributes.BOStop")>
        <!---
        Create a time object showing the current time, and format it the same
as the expected input
        --->
        <cfset variables.ThisTime=CreateODBCTime(now())>
        <cfset variables.ThisTime=TimeFormat(variables.ThisTime,'hh:mmtt')>
        <!---
        Run time comparisons on the start and stop values versus the current
time object
        --->
        <cfset 
variables.CompareStart=DateCompare(attributes.BOStart,variables.ThisTime,"N")>
        <cfset 
variables.CompareStop=DateCompare(attributes.BOStop,variables.ThisTime,"N")>
        <!---
        Compare the start and stop times and use the result to run the
following case statement
        --->
        <cfset 
variables.CompareMe=DateCompare(attributes.BOStart,attributes.BOStop,"N")>
        <cfswitch expression="#variables.CompareMe#">
                <cfcase value="-1,0">
                        <!---
                        The expected case: start is before or equal to stop
                        --->
                        <cfif (variables.CompareStart eq 0 or 
variables.CompareStart eq -1)
and (variables.CompareStop eq 0 or variables.CompareStop eq 1)>
                                <cfset caller.blackedout="Y">
                        </cfif>
                </cfcase>
                <cfcase value="1">
                        <!---
                        start is *after* stop.  This time span must cross 
midnight
                        --->
                        <cfif (variables.CompareStart eq 0 or 
variables.CompareStart eq 1)
and (variables.CompareStop eq 0 or variables.CompareStop eq 1)>
                                <cfset caller.blackedout="Y">
                        </cfif>
                </cfcase>
        </cfswitch>     
</cfif>

--
--mattRobertson--
Janitor, MSB Web Systems
mysecretbase.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222872
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to