Warren Selby
2010-Jul-13 16:30 UTC
[asterisk-users] STRFTIME function declared in globals context
I'm trying to declare a few date-related global variables to ease my
dialplan. When I declare the following in the [globals] context of
extensions.conf, I get unexpected results:
YEAR = ${STRFTIME(${EPOCH},,%Y)}
MONTH = ${STRFTIME(${EPOCH},,%m)}
DAY = ${STRFTIME(${EPOCH},,%d)}
TIMESTAMP = ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}
If I evaluate these variables in the dialplan later, using
exten => 7777,n,Verbose(${TIMESTAMP} - ${YEAR} - ${MONTH} - ${DAY})
My output is as follows:
-- Executing [7777 at phones:3] Verbose("SIP/2625-0000d5f0",
"Tue Jul 13
11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue
Jul 13 11:08:42 2010") in new stack
Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42
2010 - Tue Jul 13 11:08:42 2010
However, the following line:
exten => 7777,n,Verbose(${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} -
${STRFTIME(${EPOCH},,%Y)} - ${STRFTIME(${EPOCH},,%m)} -
${STRFTIME(${EPOCH},,%d)})
evaluates with what I expect:
-- Executing [7777 at phones:4] Verbose("SIP/2625-0000d5f0",
"20100713-110853 - 2010 - 07 - 13") in new stack
20100713-110853 - 2010 - 07 - 13
Is what I'm trying to do possible? It seems like it's at least
recognizing
that I'm trying to grab a date, but it's not taking the date format
parameters that I want.
--
Thanks,
--Warren Selby
http://www.selbytech.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.digium.com/pipermail/asterisk-users/attachments/20100713/68f58207/attachment.htm
Danny Nicholas
2010-Jul-13 16:47 UTC
[asterisk-users] STRFTIME function declared in globals context
_____
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Warren Selby
Sent: Tuesday, July 13, 2010 11:31 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] STRFTIME function declared in globals context
I'm trying to declare a few date-related global variables to ease my
dialplan. When I declare the following in the [globals] context of
extensions.conf, I get unexpected results:
YEAR = ${STRFTIME(${EPOCH},,%Y)}
MONTH = ${STRFTIME(${EPOCH},,%m)}
DAY = ${STRFTIME(${EPOCH},,%d)}
TIMESTAMP = ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}
If I evaluate these variables in the dialplan later, using
exten => 7777,n,Verbose(${TIMESTAMP} - ${YEAR} - ${MONTH} - ${DAY})
My output is as follows:
-- Executing [7777 at phones:3] Verbose("SIP/2625-0000d5f0",
"Tue Jul 13
11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue
Jul 13 11:08:42 2010") in new stack
Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42
2010 - Tue Jul 13 11:08:42 2010
However, the following line:
exten => 7777,n,Verbose(${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} -
${STRFTIME(${EPOCH},,%Y)} - ${STRFTIME(${EPOCH},,%m)} -
${STRFTIME(${EPOCH},,%d)})
evaluates with what I expect:
-- Executing [7777 at phones:4] Verbose("SIP/2625-0000d5f0",
"20100713-110853 - 2010 - 07 - 13") in new stack
20100713-110853 - 2010 - 07 - 13
Is what I'm trying to do possible? It seems like it's at least
recognizing
that I'm trying to grab a date, but it's not taking the date format
parameters that I want.
--
Thanks,
--Warren Selby
http://www.selbytech.com
--
You don't state which version you are on (These things change from 1.2 to
1.4 to 1.6/8), but that being said, you would probably more likely to
succeed doing Set(GLOBAL) in an isolated context instead of using the
[global] context for this bit of voodoo. Looking forward to a better answer
(folks like to correct my shots across the bow).
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.digium.com/pipermail/asterisk-users/attachments/20100713/07283db7/attachment.htm
Barry Miller
2010-Jul-13 17:07 UTC
[asterisk-users] STRFTIME function declared in globals context
On Tue, Jul 13, 2010 at 11:30:44AM -0500, Warren Selby wrote:> I'm trying to declare a few date-related global variables to ease my > dialplan. When I declare the following in the [globals] context of > extensions.conf, I get unexpected results: > > YEAR = ${STRFTIME(${EPOCH},,%Y)} > MONTH = ${STRFTIME(${EPOCH},,%m)} > DAY = ${STRFTIME(${EPOCH},,%d)} > TIMESTAMP = ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} > > If I evaluate these variables in the dialplan later, using > > exten => 7777,n,Verbose(${TIMESTAMP} - ${YEAR} - ${MONTH} - ${DAY}) > > My output is as follows: > > -- Executing [7777 at phones:3] Verbose("SIP/2625-0000d5f0", "Tue Jul 13 > 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue > Jul 13 11:08:42 2010") in new stack > Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 > 2010 - Tue Jul 13 11:08:42 2010 > > However, the following line: > > exten => 7777,n,Verbose(${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} - > ${STRFTIME(${EPOCH},,%Y)} - ${STRFTIME(${EPOCH},,%m)} - > ${STRFTIME(${EPOCH},,%d)}) > > evaluates with what I expect: > > -- Executing [7777 at phones:4] Verbose("SIP/2625-0000d5f0", > "20100713-110853 - 2010 - 07 - 13") in new stack > 20100713-110853 - 2010 - 07 - 13 > > Is what I'm trying to do possible? It seems like it's at least recognizing > that I'm trying to grab a date, but it's not taking the date format > parameters that I want.Try adding "preload => func_strings.so" to modules.conf -- Barry
Tilghman Lesher
2010-Jul-13 18:15 UTC
[asterisk-users] STRFTIME function declared in globals context
On Tuesday 13 July 2010 11:30:44 Warren Selby wrote:> I'm trying to declare a few date-related global variables to ease my > dialplan. When I declare the following in the [globals] context of > extensions.conf, I get unexpected results: > > YEAR = ${STRFTIME(${EPOCH},,%Y)} > MONTH = ${STRFTIME(${EPOCH},,%m)} > DAY = ${STRFTIME(${EPOCH},,%d)} > TIMESTAMP = ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}When you load the dialplan, do you see the global variables getting set? That would at least tell you whether the problem lies at the point where the values are loaded into memory, or later, at evaluation time. -- Tilghman Lesher Digium, Inc. | Senior Software Developer twitter: Corydon76 | IRC: Corydon76-dig (Freenode) Check us out at: www.digium.com & www.asterisk.org