Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Time of day check.

I am working with UCCX 5.0(2) and would just like to have different prompts played in 5 min intervals for the last half hour of the day.  This is what I have been trying to do but TAC is saying that I need to use T[now].hour and T[now].min to actually accomplish my goal.  Can someone please help me out with using the new variables.

Time of Day.JPG

5 REPLIES

Re: Time of day check.

What you are doing looks like it should work.  does it?  I could be wrong.

The way you are check your times could be done a little differently.  Notice that I check the times closest to closing first, and am moving away from it.

if (t[now] >= closing) {

     play prompt (closed)

     goto label0

}

if (t[now] >= five_til_closing) {

     play prompt (five_til_closing_prompt)

     goto label0

}

if (t[now] >= ten_til_closing) {

     play prompt (ten_til_closing_prompt)

     goto label0

}

if (t[now] >= fifteen_til_closing) {

     play prompt (fifteen_til_closing_prompt)

     goto label0

}

/* so on and so forth */

:label0

If you wanted to get real geeky, you could write some java that returned the time period you were in, e.g., "15", then build your prompt name with that value, and play it.

i.e., if it's 4:46, the java returns a variable time_period which holds the value "15", you play prompt "msg_" + time_period + "_til_closing.wav"

But that's pretty geeky, and not many people would know how to support it.  You're better off with what you have already.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Community Member

Re: Time of day check.

It will work for a day but not past 24 hours.....this is what tac had to say....

Because you are using the T[now] expression what we believe is the problem is that Time objects cannot be compared by simply using greater than or less than symbols.  These symbols are meant to compare numeric values, so the key is to get the time into numeric values that can be compared. 

This is done using the .hour and .min operations.  These pull the current hour and minutes from the time object, and store them as a single number.  Then, each of these numbers can be compared.

At this point the expression in the step is not valid which is why whenever you re-upload and refresh, the script works as the value is read and meets the criteria, but it fails once it gets past the 24 hour mark; the express is not able to compare to the necessary value.

Re: Time of day check.

There is some validity to that.

If the caller called in at 11:59:03 pm, and you wanted to know if the current time was greater or less, and the current time is now the next day @ 12:00:01 am, this wouldn't work.

t[00:00:01 am] is not greater than t[11:59:03 pm]

But you are not checking for times which span midnight, only times that span 5:00pm or so, so you would be fine.

And also, Time objects can be compared by inequalities or even equalities.  They get automatically converted to their long value.

t[10:00:00 am] > t[9:00:00 am] is valid and will always return true.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Re: Time of day check.

All,

You can also use getTime() function which will give you the time in milliseconds since GMT.  If you want to use an inequality to compare dates, this method is guaranteed to work.

     Example:  T[now].getTime()  > T[4:50:55 PM].getTime()

Steven

Please help us make the communities better. Rate helpful posts!

Re: Time of day check.

This is an unnecessary step, as comparing Time objects works in the same way, and is also guaranteed to work.

(end > start)

vs

(end.getTime() < start.getTime())

One scenario this would be the preferred method is if you were starting with a base time and checking against offsets of that time:

now = t[now].getTime()

closing_time = closing.getTime()

five_minutes = 5 * 60 * 1000

ten_minutes = 10 * 60 * 1000

fifteen_minutes = 15 * 60 * 1000

if (now >= closing_time) {

     play prompt (closed)

     goto label0

}

if (now >= closing_time - five_minutes) {

     play prompt (five_til_closing_prompt)

     goto label0

}

if (now >= closing_time - ten_minutes) {

     play prompt (ten_til_closing_prompt)

     goto label0

}

if (now >= closing_time - fifteen_minutes) {

     play prompt (fifteen_til_closing_prompt)

     goto label0

}

/* so on and so forth */

:label0

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
388
Views
15
Helpful
5
Replies
CreatePlease to create content