Discussion:
[asterisk-users] Asterisk dialplan date and time operations
Erik Wartusch
2008-01-02 10:45:38 UTC
Permalink
Hi all,

Im using Asterisk 1.4.11 and I want to proceed some time and date operations
in my dial plan. (for a time shifted callback).

Should look like:

CURRENT TIME + x minutes.

Of course it should increase the hours for example in this case:

10.59 + 5 minutes = 11.04

I guess I've to use the math function in 1.4 but how can I manage easily the
time operations?

Kind Regards,

Erik
Doug Lytle
2008-01-02 12:23:57 UTC
Permalink
Post by Erik Wartusch
Hi all,
Im using Asterisk 1.4.11 and I want to proceed some time and date operations
in my dial plan. (for a time shifted callback).
If you'll be using call files to do this, you can 'touch' them to a
future date and Asterisk will not act on them until that date is reached.

Doug
--
Ben Franklin quote:

"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."
Erik Wartusch
2008-01-02 13:16:15 UTC
Permalink
Thanks Doug.
Yes. Thats what I plan to do and allready knew about. But I want to know
wether there is an easy option to operate with times (add x minutes to a
time) or not? My research until now wasn't successful and I'm wondering that
nobody before had this problem... (date and time manipulation)
Cheers,

Erik
Post by Doug Lytle
Post by Erik Wartusch
Hi all,
Im using Asterisk 1.4.11 and I want to proceed some time and date
operations in my dial plan. (for a time shifted callback).
If you'll be using call files to do this, you can 'touch' them to a
future date and Asterisk will not act on them until that date is reached.
Doug
Tilghman Lesher
2008-01-02 15:43:28 UTC
Permalink
Post by Erik Wartusch
Yes. Thats what I plan to do and allready knew about. But I want to know
wether there is an easy option to operate with times (add x minutes to a
time) or not? My research until now wasn't successful and I'm wondering
that nobody before had this problem... (date and time manipulation)
There is not. However, if you convert your time to seconds, then it's
naturally easy to do math, and you can then convert the format back.
You can use the dialplan functions STRPTIME() and STRFTIME() to help you
with the conversions.
--
Tilghman
dave cantera
2008-01-02 15:02:43 UTC
Permalink
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffcc" text="#330000">
erik,<br>
you can start here:<br>
<a class="moz-txt-link-freetext" href="http://www.voip-info.org/wiki-Asterisk+cmd+GotoIfTime">http://www.voip-info.org/wiki-Asterisk+cmd+GotoIfTime</a><br>
<a class="moz-txt-link-freetext" href="http://www.asteriskguru.com/tutorials/gotoiftime.html">http://www.asteriskguru.com/tutorials/gotoiftime.html</a><br>
daveC<br>
<br>
Erik Wartusch wrote:
<blockquote cite="mid:***@deuromedia.at" type="cite">
<pre wrap="">Hi all,

Im using Asterisk 1.4.11 and I want to proceed some time and date operations
in my dial plan. (for a time shifted callback).

Should look like:

CURRENT TIME + x minutes.

Of course it should increase the hours for example in this case:

10.59 + 5 minutes = 11.04

I guess I've to use the math function in 1.4 but how can I manage easily the
time operations?

Kind Regards,

Erik

_______________________________________________
--Bandwidth and Colocation Provided by <a class="moz-txt-link-freetext" href="http://www.api-digital.com">http://www.api-digital.com</a>--

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
<a class="moz-txt-link-freetext" href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a>



</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="132">--
My wife's sister is in California.
I should buy her a Videophone2008!

Truly, The Next Best Thing to Being There!
--

WorldWideVideoPhones.com
856.380.0894


</pre>
</body>
</html>
Erik Wartusch
2008-01-02 15:34:24 UTC
Permalink
daveC,

No it's even simpler. ( I dont need an IF case)
I just want to add e.g. 15 minutes to the current date / time:

So simply said:

${STRFTIME(${EPOCH},,%Y%m%d%H%M)} + 15 minutes!

My question was how can I do that.? Of yourse e.g. if it's 23.57 pm and I add
15 minutes the day should increase +1 and the hours start with 0:x the
minutes with 12 ( and not 72 as the normal addition would result).

Kind Regards,

Erik
Post by dave cantera
erik,
http://www.voip-info.org/wiki-Asterisk+cmd+GotoIfTime
http://www.asteriskguru.com/tutorials/gotoiftime.html
daveC
Hi all,
Im using Asterisk 1.4.11 and I want to proceed some time and date
operations in my dial plan. (for a time shifted callback).
CURRENT TIME + x minutes.
10.59 + 5 minutes = 11.04
I guess I've to use the math function in 1.4 but how can I manage easily
the time operations?
Kind Regards,
Erik
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
asterisk-users mailing list
http://lists.digium.com/mailman/listinfo/asterisk-users
--
=======================================

Erik Wartusch
Deuromedia Technologies GmbH
Barichgasse 40-42
1030 Wien
Austria

Phone: +43 16986442 1205
Fax: +43 16986442 200
email: ***@deuromedia.at

www.deuromedia.com
dave cantera
2008-01-02 16:11:13 UTC
Permalink
erik,
cool, there are so many functions in *, it takes a long time to learn
the shortcuts!
thanks erik!
daveC
Post by Erik Wartusch
daveC,
No it's even simpler. ( I dont need an IF case)
${STRFTIME(${EPOCH},,%Y%m%d%H%M)} + 15 minutes!
My question was how can I do that.? Of yourse e.g. if it's 23.57 pm and I add
15 minutes the day should increase +1 and the hours start with 0:x the
minutes with 12 ( and not 72 as the normal addition would result).
Kind Regards,
Erik
Post by dave cantera
erik,
http://www.voip-info.org/wiki-Asterisk+cmd+GotoIfTime
http://www.asteriskguru.com/tutorials/gotoiftime.html
daveC
Hi all,
Im using Asterisk 1.4.11 and I want to proceed some time and date
operations in my dial plan. (for a time shifted callback).
CURRENT TIME + x minutes.
10.59 + 5 minutes = 11.04
I guess I've to use the math function in 1.4 but how can I manage easily
the time operations?
Kind Regards,
Erik
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
asterisk-users mailing list
http://lists.digium.com/mailman/listinfo/asterisk-users
--
My wife's sister is in California.
I should buy her a Videophone2008!

Truly, The Next Best Thing to Being There!
--

WorldWideVideoPhones.com
856.380.0894
Tilghman Lesher
2008-01-02 17:59:06 UTC
Permalink
Post by Erik Wartusch
No it's even simpler. ( I dont need an IF case)
${STRFTIME(${EPOCH},,%Y%m%d%H%M)} + 15 minutes!
My question was how can I do that.? Of yourse e.g. if it's 23.57 pm and I
add 15 minutes the day should increase +1 and the hours start with 0:x the
minutes with 12 ( and not 72 as the normal addition would result).
${STRFTIME($[${EPOCH} + (15 * 60)],,%Y%m%d%H%M)}
--
Tilghman
Erik Wartusch
2008-01-03 09:02:49 UTC
Permalink
Thanks!

I got it now!

Here is a sample for a delayed callback after a caller gets to a users
voicemailbox. Purpose: Reminder for people that they got a message on their
v. box.

exten => 1002,1,Answer
exten => 1002,2,Set(CHANNEL(musicclass)=default)
exten => 1002,3,Queue(test|t|||5)
exten => 1002,4,Voicemail(b1205)
exten => 1002,5,System(echo -e "Channel: SIP/we-static\\nCallerID:
VOICEMAIL
<8500>\\nContext: test\\nExtension: 444" > /tmp/${UNIQUEID}.call)
; add 15 minutes (in seconds 900) to the epoch time
exten => 1002,6,Set(newepoch=${MATH(${EPOCH} + 900 |int)})
; write it out for debugging purpose
exten => 1002,7,NoOp(${newepoch})
exten => 1002,8,System(touch -t ${STRFTIME(${newepoch},,
%Y%m%d%H%M)} /tmp/${
UNIQUEID}.call)
exten =>
1002,9,System(mv /tmp/${UNIQUEID}.call /var/spool/asterisk/outgoing
/)
exten => 1002,10,Hangup


Kind Regards,

Erik
Post by Tilghman Lesher
Post by Erik Wartusch
No it's even simpler. ( I dont need an IF case)
${STRFTIME(${EPOCH},,%Y%m%d%H%M)} + 15 minutes!
My question was how can I do that.? Of yourse e.g. if it's 23.57 pm and I
add 15 minutes the day should increase +1 and the hours start with 0:x
the minutes with 12 ( and not 72 as the normal addition would result).
${STRFTIME($[${EPOCH} + (15 * 60)],,%Y%m%d%H%M)}
Loading...