Decimal Seconds?
Hi.
I’m looking at https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Function_STRFTIME and trying to work out how to obtain an Epoch timestamp for “now” containing fractional / decimal seconds so that the %3q format parameter works.
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Standard+Channel+Variables doesn’t seem to tell me.
Can someone point me in the right direction please?
Antony.
—
I lay awake all night wondering where the sun went, and then it dawned on me.
Please reply to the list;
please *don’t* CC me.
—
4 thoughts on - Decimal Seconds?
Hi.
Has nobody got a clue for me about this?
It must be possible somehow, otherwise the %3q parameter wouldn’t exist…
—
My life is going completely according to plan.
I do sometimes wish it had been *my* plan, though.
Please reply to the list;
please *don’t* CC me.
—
What have you actually tried? STRFTIME(NOW,America/Detroit,%3q) doesn’t work?
—–Original Message—– —
From: asterisk-users
My life is going completely according to plan.
I do sometimes wish it had been *my* plan, though.
Please reply to the list;
please *don’t* CC me.
—
That works – thank you for the pointer. I was not aware of the word “NOW” – I
have always used the variable ${EPOCH} when I needed a timestamp.
Do you know where this is documented? I would have expected it to be in https://wiki.asterisk.org/wiki/display/AST/Asterisk+Standard+Channel+Variables for example, which does mention ${EPOCH}, and also shows an example of
${STRFTIME()}, using ${EPOCH} as the timestamp value.
Antony.
—
Programming is a Dark Art, and it will always be. The programmer is fighting against the two most destructive forces in the universe:
entropy and human stupidity. They’re not things you can always overcome with a “methodology” or on a schedule.
– Damian Conway, Perl God
Please reply to the list;
please *don’t* CC me.
—
Hi Antony,
NOW is not a variable…
In the majority of cases (the exceptions are things like CUT)… variables are utilized by ${}
If NOW was a variable you would see it written as ${NOW}
The word NOW is actually not special. Deep in the Asterisk source (if you are curious), the flow is this:
acf_strftime
-> ast_get_timeval
“NOW” gets passed as a string to ast_get_timeval, which really scans for a numeric unixtime. If the scan fails (if the input is not a proper seconds-since-epoch-unixtime), then it uses a default.
Oddly enough you could pass “POTATO” to STRFTIME and it would work just fine… since no matter what the value is, if it doesn’t parse properly the default is ast_tvnow which is a high resolution ‘now’
—