<div dir="ltr"><div dir="ltr"><div dir="ltr">Try using the STRFIME function instead of doing this by hand.<br><br><a href="https://wiki.asterisk.org/wiki/display/AST/Function_STRFTIME">https://wiki.asterisk.org/wiki/display/AST/Function_STRFTIME</a><br><br><p><b>%H</b>

</p><p>The hour as a decimal number using a 24-hour clock (range 00 to 23).

</p><p><b>%I</b>

</p><p>The hour as a decimal number using a 12-hour clock (range 01 to 12).

</p></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 13, 2020 at 3:49 AM Dovid Bender <<a href="mailto:dovid@telecurve.com">dovid@telecurve.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<br><div><br></div><div>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:<br>Exten => 2,1,ExecIf(${MATH(${HOUR_SELECTED}<12)}?Set(HOUR_SELECTED=${MATH(${HOUR_SELECTED}+12,int)}))<br></div><div><br></div><div>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?</div><div><br></div><div>The exact DP code is:</div><div>Exten => 2,     1, Noop(BEFORE CHECK HOUR_SELECTED is ${HOUR_SELECTED})<br> same =>        n, ExecIf(${MATH(${HOUR_SELECTED}<12)}?Set(HOUR_SELECTED=${MATH(${HOUR_SELECTED}+12,int)}))<br> same =>        n, Noop(AFTER CHECK HOUR_SELECTED IS ${HOUR_SELECTED})<br></div><div><br></div><div>And the output of the logs is:</div><div>[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<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Result of 'HOUR_SELECTED' is '12'<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Function MATH(12<12) result is 'FALSE'<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Result of 'HOUR_SELECTED' is '12'<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Function MATH(12+12,int) result is '24'<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx.c: Launching 'ExecIf'<br>[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<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx_variables.c: Result of 'HOUR_SELECTED' is '24'<br>[Feb 13 10:46:18] DEBUG[1580][C-00007bc6] pbx.c: Launching 'NoOp'<br>[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<br></div><div><br></div><div><br></div><div>TIA.</div><div><br></div><div>Dovid</div><div><br></div></div>
-- <br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
Check out the new Asterisk community forum at: <a href="https://community.asterisk.org/" rel="noreferrer" target="_blank">https://community.asterisk.org/</a><br>
<br>
New to Asterisk? Start here:<br>
      <a href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki/display/AST/Getting+Started</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" rel="noreferrer" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">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.<br>---Heinlein</div>