cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2911
Views
0
Helpful
7
Replies

Set Time of Day for Open and Close

Perry Camacho
Level 1
Level 1

I've been trying to different formats to get an open and close parameter to work. Basically I'm trying to compare the current time, depending on Time zone, to an open and close time and then it should go to the open menu or closed menu. I'm using an XML file to pull open and closed times. The first is a syntax I found on this forum that doesn't work at all. The UCCX keeps saying that it is incorrect:

if (T[T[now], TZ[America/Chicago]] >=OpenTime) && (T[T[now], TZ[America/Chicago]]<=CloseTime)

Where OpenTime and CloseTime are intergers

The second is simpler:

Set sTime=(T[T[now], TZ[America/Chicago]])

if (sTime>=OpenTime)&&(sTime<=CloseTime)

Where OpenTime and CloseTime are string values

The first, as I stated earlier, just won't be accepted and the second pulls all the info but doesn't actually do anything and it always goes to the closed menu.

I almost forgot to state that my XML returns a value of 8:30 AM for OpenTime and 5:00 PM for ClosedTime, the UCCX returns a value of whatever time it is in that time zone as, for example, 2:30 PM. But I still get sent to the closed menu.

I just tried changing the syntax to read:

((T[T[now], TZ[America/Chicago]]) >= T[OpenTime] && (T[T[now], TZ[America/Chicago]]) < T[CloseTime])

Where OpenTime and CloseTime are string values pulled from my XML and I get back the an exception of incompatible types: com.cisco.util.DateLiteral; expecting java.sql.Time. I've tried every combination of time as a string value and nothing works. Can someone tell me what the UCCX is looking for? I've read that java.sql.Time is Hours, Minutes, Seconds, but I've tried every combination of that as well and nothing works.

Thanks for any help anyone can give me.

1 Accepted Solution

Accepted Solutions

Set sTime = ((T[T[now], TZ[America/Chicago]]), this gives me the time in that zone

Are you sure?  Did you verify sTime in a debug?  AFAIK time objects are not time zone aware, therefore trying to apply a time zone to a time object doesn't make sense.  In my experience if you're using time objects with time zones you will have problems. So maybe your check is failing because you're off by an hour or two?

Other than using date objects the other thing you could to is to (temporarily) split your if statement up into two individual checks.  For example can you even get this to work?
    if (sTime >= OpenTime)
    true: do thing A
    false: do thing B

I also use before and after methods instead of comparison operators, not sure if that matters here.

You can read more details about TOD checking here.

Good luck!

View solution in original post

7 Replies 7

jim-j
Level 3
Level 3

If you need time zone awareness then you  should be using date variables.  Below is some example code using a date variable:

Set timeToCheck_date = D[now] //This is eastern time in my case
Set todaysDate_str = D[now] //gets set to something like "2/8/2017"
Set timeZone_tz = "America/Chicago"
Set startTime_str = "4:00 PM"
Set startTime_date = D[todaysDate_str + " " + startTime_str, timeZone_tz]
If timeToCheck_date.after(startTime_date)
    True = timeToCheck occurs after the startTime
    False = timeToCheck occurs before the startTime

Hi Dravet,

First, let me say thank you for the response, this thing has me scratching my head quite a bit. I like the script example, but I still end up with the same issue, how to compare the current time with the open and close times. I pull the time with timezone with one simple line:

Set sTime = ((T[T[now], TZ[America/Chicago]]), this gives me the time in that zone

My problem is when I try to compare my sTime with my open and close time, it just ignores it. The set command I'm using pulls a time in this format 8:30 AM, my Opentime is being pulled from my XML as 8:00 AM and my CloseTime as 5:00 PM, but my comparison:

sTime >= OpenTime && sTime < CloseTime

This returns nothing and it goes to the closed menu. This really shouldn't be so complicated. I've even enclosed the first and second half of my statement, eg. (sTime >= OpenTime) && (sTime < CloseTime) and still does nothing. How do I compare the sTime to my open and close times?

I forgot to add that my platform is UCCX 11.0.1, if that helps answer this question.

I sincerely appreciate any and help, Perry.

Set sTime = ((T[T[now], TZ[America/Chicago]]), this gives me the time in that zone

Are you sure?  Did you verify sTime in a debug?  AFAIK time objects are not time zone aware, therefore trying to apply a time zone to a time object doesn't make sense.  In my experience if you're using time objects with time zones you will have problems. So maybe your check is failing because you're off by an hour or two?

Other than using date objects the other thing you could to is to (temporarily) split your if statement up into two individual checks.  For example can you even get this to work?
    if (sTime >= OpenTime)
    true: do thing A
    false: do thing B

I also use before and after methods instead of comparison operators, not sure if that matters here.

You can read more details about TOD checking here.

Good luck!

100%, please try it, works perfectly. I'm in Central time and I've tested it with all 4 time zones. That's a great idea, let me see if I can make it work. I'll let you know and thanks again, this is very helpful.

No Joy! I'm beginning to believe this is a bug. Everything looks perfect but it just doesn't work. If I get any info from Cisco I'll let you know and thank you again Sir!

Hi Dravet,

I just want to say thank you and for pointing me in the right direction. I've attached a screenshot of my script. Believe it or not, it works perfectly. The open/close times are string values from my XML file in "8:30 AM" time format. I have 4 added since I couldn't figure out how to get the line to accept my TZ from my XML, so be it, minor inconvenience. Please check it out and try it if you like, works great. I know I could've made it one line, but I kinda like it like this.

Thanks again, Perry.

Your script makes sense to me. Glad you got it working.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: