cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1659
Views
5
Helpful
5
Replies

Script to convert seconds to minutes

Neel.N.Sheth_2
Level 1
Level 1

Does anyone have a useful script that can convert seconds into minutes?  Any help would be greatly appreciated.

5 Replies 5

Anthony Holloway
Cisco Employee
Cisco Employee

set seconds = 320

set minutes = seconds / 60

set seconds = seconds % 60

That will take 320 seconds, store 5 as the minute value, and then overwrite your 320 with 20 seconds, giving you:

minutes = 5

seconds = 20

I was able to create a script to convert the seconds to minutes, after giving it some thought, but my problem now is how to create a generated prompt to take the variable "min" and play it back to the user (ie. 5 mins, less than 1 min, etc.).  I looked at the constructor types under the Create Generated Prompt step, but nothing is there for mins only.  I can do time, but I need hours and mins.  I went ahead and calculated the hours too, but all I get is "12:01AM" for the prompt, because the hour variable is set to 0 and the sec variable is set to 1.

In doing some reading on using the time constructor type, it says that if the value is over 2359, then the system treats it as millisecs.  Do I need to convert the min variable to millisecs to get the proper generated prompt?

This would work:

/* if minutes = 5; "Five minutes" */
play prompt(--triggering contact--, n[minutes] + sp[gen/time/minutes])

Explanation:

n[] = Number prompt.  This will say the number in the variable; e.g., 16 = Sixteen, 77 = seventy-seven

+ = Prompt concatenation operator.  Combines two or more prompts together.

sp[] = System prompt.  Plays a system prompt in the locale of the contacts language. (Usually the trigger's language [Usually the system's langauge])

Question: Would the above work if minutes < 2?  If not, how could you improve the script, so that it would?

The system prompts!!  Uhh, I forgot about those!!  Thanks a lot!!

As for the script, here's what I was doing.  Would this not work?


sec = 130

min = 1

Well, I don't see any errors, but, it's certainly not a full solution. Do you need help with something specific in your script now, or are you on your way to success?  If success, please do not forget to rate each helpful post!  Thanks.