Extensions.conf calculations

Hi, I have been looking through several platforms and posts to determine how to add 2 two numbers in a Extension.conf file. i.e. I want to calculate the total minutes that has gone by based on the time of day and will use to generate random numbers. I have many different methods which I have Cleary not got right. Please help - Thank you

same => n,Set(MSTHrs=${STRFTIME(${EPOCH},%H)})
same => n,Set(MSTMins=${STRFTIME(${EPOCH},%M)})
same => n,Set(MSTTotal=(${MSTHrs}*60)+${MSTMins}))

On Tuesday 13 August 2024 at 14:34:54, AskLearner via Asterisk Community
wrote:

Hi, I have been looking through several platforms and posts to determine
how to add 2 two numbers in a Extension.conf file. i.e. I want to
calculate the total minutes that has gone by based on the time of day and
will use to generate random numbers. I have many different methods which
I have Cleary not got right. Please help - Thank you

same => n,Set(MSTHrs=${STRFTIME(${EPOCH},%H)})
same => n,Set(MSTMins=${STRFTIME(${EPOCH},%M)})
same => n,Set(MSTTotal=(${MSTHrs}*60)+${MSTMins}))

  1. As a general rule when asking “what’s wrong with this?” it’s a very good
    idea to say what it does do (instead of what you wanted it to do) rather
    than simply saying “it doesn’t work” or “it’s not right”.

  2. Asterisk requires arithmetic statements to be placed in square brackets,
    therefore your addition statement should be:

same => n,Set(MSTTotal=$[${MSTHrs}*60+${MSTMins}]

Antony.

–
We all get the same amount of time - twenty-four hours per day.
How you use it is up to you.

                                               Please reply to the list;
                                                     please *don't* CC me.
1 Like

Why not just use $[${EPOCH}/60] ? (Or rather do so on the difference.)

1 Like

Thank you appreciate the help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.