I found my mistake. I was running execif on the result. I needed to change:
ExecIf(${MATH(${HOUR_SELECTED}<11)}?Set(HOUR_SELECTED=${MATH(${HOUR_SELECTED}+12,int)}))
TO:
ExecIf($["${MATH(${HOUR_SELECTED}<11)}" ==
"TRUE"]?Set(HOUR_SELECTED=${MATH(${HOUR_SELECTED}+12,int)}))On Thu, Feb 13, 2020 at 2:12 PM Dovid Bender <[email protected]> wrote: > John, > > That is correct. I am trying to figure out why Asterisk is executing the > set part of the execif, if it's coming back as false. > > > > On Thu, Feb 13, 2020 at 2:10 PM John Kiniston <[email protected]> > wrote: > >> My Apologies Dovid, I think I misunderstood your request. >> >> You don't have the time you need to convert in the format of date string, >> Instead you have your users entering via DTMF when they want something to >> happen? >> >> On Thu, Feb 13, 2020 at 11:08 AM Dovid Bender <[email protected]> >> wrote: >> >>> John, >>> >>> From looking at the wiki won't STRFIME just give me what I need based on >>> the unix time that I put in? What I am actually looking to do is convert >>> over from 12 hour format to 24 (unless strftime does just that and I don't >>> kow what am I am doing?). >>> >>> >>> >>> On Thu, Feb 13, 2020 at 12:03 PM John Kiniston <[email protected]> >>> wrote: >>> >>>> Try using the STRFIME function instead of doing this by hand. >>>> >>>> https://wiki.asterisk.org/wiki/display/AST/Function_STRFTIME >>>> >>>> *%H* >>>> >>>> The hour as a decimal number using a 24-hour clock (range 00 to 23). >>>> >>>> *%I* >>>> >>>> The hour as a decimal number using a 12-hour clock (range 01 to 12). >>>> >>>> On Thu, Feb 13, 2020 at 3:49 AM Dovid Bender <[email protected]> >>>> wrote: >>>> >>>>> Hi, >>>>> >>>>> I have some dialplan code that is trying to convert 12 hour time with >>>>> AM/PM to 24 hour format. The code has something like this: >>>>> Exten => >>>>> 2,1,ExecIf(${MATH(${HOUR_SELECTED}<12)}?Set(HOUR_SELECTED=${MATH(${HOUR_SELECTED}+12,int)})) >>>>> >>>>> Earlier on in the dialplan HOUR_SELECTED is set to 12. When they press >>>>> option 2 they are selecting PM. If the time is from 1PM to 11PM then I >>>>> want >>>>> to add 12 to the number (so if it's 1 make it 13 etc.). When I run the >>>>> above the logs show the result as false yet if the user sets HOUR_SELECTED >>>>> to 12 then after this line of dialplan code it gets switched to 24. What >>>>> am >>>>> I doing wrong here? >>>>> >>>>> The exact DP code is: >>>>> Exten => 2, 1, Noop(BEFORE CHECK HOUR_SELECTED is ${HOUR_SELECTED}) >>>>> same => n, >>>>> ExecIf(${MATH(${HOUR_SELECTED}<12)}?Set(HOUR_SELECTED=${MATH(${HOUR_SELECTED}+12,int)})) >>>>> same => n, Noop(AFTER CHECK HOUR_SELECTED IS ${HOUR_SELECTED}) >>>>> >>>>> And the output of the logs is: >>>>> [Feb 13 10:46:18] VERBOSE[1580][C-00007bc6] pbx.c: Executing >>>>> [2@am_pm_select:1] NoOp("SIP/204.145.219.31-000081c6", "BEFORE CHECK >>>>> HOUR_SELECTED is 12") in new stack >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Result of >>>>> 'HOUR_SELECTED' is '12' >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Function >>>>> MATH(12<12) result is 'FALSE' >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Result of >>>>> 'HOUR_SELECTED' is '12' >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Function >>>>> MATH(12+12,int) result is '24' >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx.c: Launching 'ExecIf' >>>>> [Feb 13 10:46:18] VERBOSE[1580][C-00007bc6] pbx.c: Executing >>>>> [2@am_pm_select:2] ExecIf("SIP/204.145.219.31-000081c6", >>>>> "FALSE?Set(HOUR_SELECTED=24)") in new stack >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Result of >>>>> 'HOUR_SELECTED' is '24' >>>>> [Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx.c: Launching 'NoOp' >>>>> [Feb 13 10:46:18] VERBOSE[1580][C-00007bc6] pbx.c: Executing >>>>> [2@am_pm_select:3] NoOp("SIP/204.145.219.31-000081c6", "AFTER CHECK >>>>> HOUR_SELECTED IS 24") in new stack >>>>> >>>>> >>>>> TIA. >>>>> >>>>> Dovid >>>>> >>>>> -- >>>>> _____________________________________________________________________ >>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >>>>> >>>>> Check out the new Asterisk community forum at: >>>>> https://community.asterisk.org/ >>>>> >>>>> New to Asterisk? Start here: >>>>> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >>>>> >>>>> asterisk-users mailing list >>>>> To UNSUBSCRIBE or update options visit: >>>>> http://lists.digium.com/mailman/listinfo/asterisk-users >>>> >>>> >>>> >>>> -- >>>> A human being should be able to change a diaper, plan an invasion, >>>> butcher a hog, conn a ship, design a building, write a sonnet, balance >>>> accounts, build a wall, set a bone, comfort the dying, take orders, give >>>> orders, cooperate, act alone, solve equations, analyze a new problem, pitch >>>> manure, program a computer, cook a tasty meal, fight efficiently, die >>>> gallantly. Specialization is for insects. >>>> ---Heinlein >>>> -- >>>> _____________________________________________________________________ >>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >>>> >>>> Check out the new Asterisk community forum at: >>>> https://community.asterisk.org/ >>>> >>>> New to Asterisk? Start here: >>>> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >>>> >>>> asterisk-users mailing list >>>> To UNSUBSCRIBE or update options visit: >>>> http://lists.digium.com/mailman/listinfo/asterisk-users >>> >>> -- >>> _____________________________________________________________________ >>> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >>> >>> Check out the new Asterisk community forum at: >>> https://community.asterisk.org/ >>> >>> New to Asterisk? Start here: >>> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >>> >>> asterisk-users mailing list >>> To UNSUBSCRIBE or update options visit: >>> http://lists.digium.com/mailman/listinfo/asterisk-users >> >> >> >> -- >> A human being should be able to change a diaper, plan an invasion, >> butcher a hog, conn a ship, design a building, write a sonnet, balance >> accounts, build a wall, set a bone, comfort the dying, take orders, give >> orders, cooperate, act alone, solve equations, analyze a new problem, pitch >> manure, program a computer, cook a tasty meal, fight efficiently, die >> gallantly. Specialization is for insects. >> ---Heinlein >> -- >> _____________________________________________________________________ >> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >> >> Check out the new Asterisk community forum at: >> https://community.asterisk.org/ >> >> New to Asterisk? Start here: >> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >> >> asterisk-users mailing list >> To UNSUBSCRIBE or update options visit: >> http://lists.digium.com/mailman/listinfo/asterisk-users > >
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- Check out the new Asterisk community forum at: https://community.asterisk.org/ New to Asterisk? Start here: https://wiki.asterisk.org/wiki/display/AST/Getting+Started asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
