Re: Time Block

2005-11-01 Thread Matt Robertson
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


RE: Time Block

2005-10-31 Thread Roberto Perez
At 11:09 PM 10/30/2005, Justin Scott wrote:
If you do it the way you're doing it, you're comparing strings, not date
objects.  You should take the fields you get from the DB and use
createDateTime() to create a CF datetime object, then compare that to now()
instead of comparing strings.


Thanks for the answer. I was actually trying to use CreateDateTime with 
this code:

cfset startTimeDate= CreateDateTime(qry.applOpenYear, qry.applOpenMonth, 
qry.applOpenDay,  qry.applOpenHour, qry.applOpenMinute, qry.applOpenSecond)

but that threw a nonspecified error, and the CFSET tag would only be 
processed if I enclosed the portion after the EQUAL sign within quotes 
(which obviously converted it to a string). Any ideas on how to code this 
part so that it works?

Thanks,

Roberto Perez


~|
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:222715
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=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: Time Block

2005-10-31 Thread Justin D. Scott
 but that threw a nonspecified error, and the CFSET
 tag would only be processed if I enclosed the portion
 after the EQUAL sign within quotes (which obviously
 converted it to a string). Any ideas on how to code
 this part so that it works?

The code looks fine as far as I can tell.  Perhaps one of the fields from
the DB has an invalid value such as a null or blank string or something?  If
you post the error here it may help uncover the issue.

-Justin



~|
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:222718
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=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: Time Block

2005-10-31 Thread Roberto Perez
At 09:22 AM 10/31/2005, you wrote:

The code looks fine as far as I can tell.  Perhaps one of the fields from
the DB has an invalid value such as a null or blank string or something?  If
you post the error here it may help uncover the issue.


When I print the values on the screen, all fields have a number (for month, 
day, year, etc.). Here's the error message, which does not specify what 
type of error this is:


- - - - - - error starts here - - - - - - - - -
Error Occurred While Processing Request

The Error Occurred in 
C:\CFusionMX\wwwroot\site\inCheckApplPeriodStatus.cfm: line 10

8 : cfif getApplPeriodStatus_qry.schedulerStatusFK EQ automatic
9 : cfset thisTime='#DateFormat(Now(), 'mmm/dd/')# 
#Hour(Now())#:#Minute(Now())#:#Second(Now())#'
10 : cfset startTimeDate= 
CreateDateTime(getApplPeriodStatus_qry.applOpenYear, 
getApplPeriodStatus_qry.applOpenMonth, 
getApplPeriodStatus_qry.applOpenDay,  getApplPeriodStatus_qry.applOpenHour, 
getApplPeriodStatus_qry.applOpenMinute, 
getApplPeriodStatus_qry.applOpenSecond)
11 : cfset endTimeDate= 
'#getApplPeriodStatus_qry.applCloseMonth#/#getApplPeriodStatus_qry.applCloseDay#/#getApplPeriodStatus_qry.applCloseYear#
 
#getApplPeriodStatus_qry.applCloseHour#:#getApplPeriodStatus_qry.applCloseMinute#:#getApplPeriodStatus_qry.applCloseSecond#'
12 :cfif thisTime GTE endTimeDate OR thisTime LTE startTimeDate

- - - - -- error ends here - - - - - - - - -  -


Also, I'm including the whole code, since sometimes the debugger in CF 
points not to the problem line, but to a few lines after where the problem 
ocurs:

- - - - - - code snippet starts here - - - - - -
cfif getApplPeriodStatus_qry.schedulerStatusFK EQ automatic
cfset thisTime='#DateFormat(Now(), 'mmm/dd/')# 
#Hour(Now())#:#Minute(Now())#:#Second(Now())#'
cfset startTimeDate= CreateDateTime(getApplPeriodStatus_qry.applOpenYear, 
getApplPeriodStatus_qry.applOpenMonth, 
getApplPeriodStatus_qry.applOpenDay,  getApplPeriodStatus_qry.applOpenHour, 
getApplPeriodStatus_qry.applOpenMinute, 
getApplPeriodStatus_qry.applOpenSecond)
cfset endTimeDate= 
'#getApplPeriodStatus_qry.applCloseMonth#/#getApplPeriodStatus_qry.applCloseDay#/#getApplPeriodStatus_qry.applCloseYear#
 
#getApplPeriodStatus_qry.applCloseHour#:#getApplPeriodStatus_qry.applCloseMinute#:#getApplPeriodStatus_qry.applCloseSecond#'
 cfif thisTime GTE endTimeDate OR thisTime LTE startTimeDate
 cfset variables.applPeriodStatus=open
 cfelseif thisTime GTE startTimeDate AND thisTime LTE endTimeDate
 cfset variables.applPeriodStatus=closed
 /cfif

cfelse
cfset 
variables.applPeriodStatus=#getApplPeriodStatus_qry.applPeriodStatusFK#
/cfif

- - - - - - code snippet ends here - - - - - - -

Thanks in advance for any pointers/suggestions as to how to format both 
dates (Now and DB) for proper comparison with GTE and LTE.

Roberto Perez



~|
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:222720
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


Re: Time Block

2005-10-31 Thread Roberto Perez
At 09:22 AM 10/31/2005, Justin D. Scott wrote:

  Perhaps one of the fields from
the DB has an invalid value such as a null or blank string or something?  If
you post the error here it may help uncover the issue.


I did more narrowing down to see where the problem was exactly. I 
replaced all my variables with straight numbers, and the code worked. On 
further comparison with the example in the DW Help file, I noticed the 
values for day were 00-23, and for minutes and seconds it was 00-59. Since 
I had my time set to 24:00:00, CF did not like that format. Changing the 
time to 23:59:59 or 00:00:00 makes the code work (I guess you don't say 
24:02:10 ?). I'll also have to change the values for day and month, which 
out of habit I started at 00.

I wish there had been an error message to catch that detail.

Thanks for the help,

Roberto


~|
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:222796
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


RE: Time Block

2005-10-30 Thread Roberto Perez
At 05:17 PM 10/28/2005, Bobby Hartsfield wrote:

Even easier, once you have the dates just check to see if now() is

A) GTE EndDateTime OR LTE StartDateTime
B) GTE StartDateTime AND LTE EndDateTime

A being true means grant access
B being true means deny access


Hey,

I'm trying to implement that solution, comparing today's date with a date I 
have in a database (unfortunately, the DB I inherited has the date stored 
as individual dd, mm, yy, hh, mm, and ss fields). So I create my date with:

cfset endTimeDate= 
'#qry.applCloseMonth#/#qry.applCloseDay#/#qry.applCloseYear# 
#qry.applCloseHour#:#qry.applCloseMinute#:#qry.applCloseSecond#'
(again, from individual fields in the DB)

and then I create thisDate:

cfset thisTime='#DateFormat(Now(), 'mmm/dd/')# 
#Hour(Now())#:#Minute(Now())#:#Second(Now())#'

and although both dates print exactly the same on the screen, the 
comparison between them does not trigger an earlier that or later than 
behavior (I'm using GTE and LTE). Any suggestions on how to make it work 
(considering how the date is stored in the DB)?

Thanks in advance,

Roberto Perez
[EMAIL PROTECTED]


~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222691
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


RE: Time Block

2005-10-30 Thread Justin D. Scott
If you do it the way you're doing it, you're comparing strings, not date
objects.  You should take the fields you get from the DB and use
createDateTime() to create a CF datetime object, then compare that to now()
instead of comparing strings.


-Justin Scott



 I'm trying to implement that solution, comparing today's date 
 with a date I 
 have in a database (unfortunately, the DB I inherited has the 
 date stored 
 as individual dd, mm, yy, hh, mm, and ss fields). So I create 
 my date with:
 
 cfset endTimeDate= 
 '#qry.applCloseMonth#/#qry.applCloseDay#/#qry.applCloseYear# 
 #qry.applCloseHour#:#qry.applCloseMinute#:#qry.applCloseSecond#'
 (again, from individual fields in the DB)
 
 and then I create thisDate:
 
 cfset thisTime='#DateFormat(Now(), 'mmm/dd/')# 
 #Hour(Now())#:#Minute(Now())#:#Second(Now())#'
 
 and although both dates print exactly the same on the screen, the 
 comparison between them does not trigger an earlier that or 
 later than 
 behavior (I'm using GTE and LTE). Any suggestions on how to 
 make it work 
 (considering how the date is stored in the DB)?
 
 Thanks in advance,
 
 Roberto Perez
 [EMAIL PROTECTED]


~|
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:222693
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


RE: Time Block

2005-10-28 Thread Justin D. Scott
 Hi. I trying create a function in this format:
 IsBlockedTime(startdayofweek,starthour, startminute,
 enddayofweek, endhour,endminute)

This should be simple...  Once you have the values, create datetime objects
using createDateTime() and then use the DateDiff() function against those
and now() to determine if it is in range.  Return value as needed.


-Justin Scott



~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222592
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


RE: Time Block

2005-10-28 Thread Bobby Hartsfield
Even easier, once you have the dates just check to see if now() is 

A) GTE EndDateTime OR LTE StartDateTime
B) GTE StartDateTime AND LTE EndDateTime

A being true means grant access
B being true means deny access

StartDateTime being the time on Friday that you want to close out access and
the EndDateTime being the time on Monday that you want to start granting
access again.

Of course you could just write a couple batch files (one to start the CF or
IIS service(s) and one to stop them) then just use scheduled tasks to run
them at your desired days/times.

..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com

-Original Message-
From: Justin D. Scott [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 28, 2005 1:52 PM
To: CF-Talk
Subject: RE: Time Block

 Hi. I trying create a function in this format:
 IsBlockedTime(startdayofweek,starthour, startminute,
 enddayofweek, endhour,endminute)

This should be simple...  Once you have the values, create datetime objects
using createDateTime() and then use the DateDiff() function against those
and now() to determine if it is in range.  Return value as needed.


-Justin Scott





~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222617
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