[SR-Users] time formats (specifically in db_flatstore)

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 9 21:33:58 CEST 2010


  Hello,

On 8/9/10 6:13 PM, Henning Westerholt wrote:
> On Thursday 05 August 2010, SIP Projects wrote:
>> doh!
>>
>> here is the actual variable i'm trying to hack together:
>>
>> $var(reg_time) = $time(year) + "-" + $time(mon) + "-" + $time(mday)
>> + " " + $time(hour) + ":" + $time(min) + ":" + $time(sec);
> Hi Matt,
>
> with regards to your first question, about changing the value in the flatstore
> module, its of course possible to just change the code of the database module.
>
> I've tried your script variable in current git master, here it works (with
> some casting warnings..), and also in 1.5.2, where i could reproduce it:
>
> Aug  9 17:43:20 [987] ERROR:core:eval_elem: invalid numeric operands
> Aug  9 17:43:20 [987] ERROR:core:do_assign: no value in right expression
> Aug  9 17:43:20 [987] ERROR:core:do_assign: error at line: 30
>
> So the issue is that the script interpreter can not concat the time values
> (which are int only) to the string seperators. As i workaround i've tried to
> start with an empty string in the var:
>
> $var(reg_time) = "" + $time(year) + "-" + $time(mon) + "-" + $time(mday) + " "
> + $time(hour) + ":" + $time(min) + ":" + $time(sec);
>
> this seems to work:
>
> Entering Route TEST 2010-8-9 18:8:0

for the record: there is a function called pv_printf("$pv", "formatted 
string").

So it can be:

pv_printf("$var(reg_time)", "$time(year)-$time(mon)-$time(mday) $time(hour):$time(min):$time(sec)");

First parameter can be any PV that is writable and can hold string 
values, second is a string with variables evaluated at runtime:
http://kamailio.org/docs/modules/stable/modules_k/kex.html#id2976738

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://www.asipto.com/




More information about the sr-users mailing list