mod_dptools: strftime
About​
Displays the current time in various formats. For time zone enabled time zone function, see strftime_tz
For a list of what args are available, see this table (better link? list here?)
Usage​
strftime [format_string]
Returns the local system time. If format_string is not specified, it defaults to "%Y-%m-%d %T", eg. 2010-04-28 17:47:29
Examples​
<action application="strftime" data="%Y-%m-%d"/>
<action function="speak-text" data="You have $1 minutes, $2 seconds remaining ${strftime(%Y-%m-%d)}"/>
Routing a call differently based on time of day:
<extension name="Time_Routing">
<condition field="${strftime(%H%M)}" expression="^((09|1[0-7])[0-5][0-9]|1800)$">
<action application="bridge" data="sofia/$${domain}/1000"/>
<anti-action application="voicemail" data="$${profile} $${domain} 1000"/>
</condition>
</extension>
Example of doing things based on time of day:
Time of Day example
<extension name="tod_example">
<!-- First, match M-F; if not M-F then we're definitely closed -->
<condition field="${strftime(%w)}" expression="^([1-5])$">
<anti-action application="set" data="business=Sat"/>
<anti-action application="transfer" data="IVR_Sat"/>
</condition>
<!-- Next, check time of day. First regex is to match 7:30am to 11:59am -->
<condition field="${strftime(%H%M)}" expression="^((07[3-5][0-9])|((08|09|1[0-1])[0-5][0-9]))$">
<action application="set" data="business=morning"/>
<action application="transfer" data="IVR_Open"/>
<anti-action application="set" data="business=lunch"/>
<anti-action application="transfer" data="IVR_Lunch"/>
</condition>
</extension>
<extension name="Play Lunch IVR">
<condition field="destination_number" expression="^IVR_Lunch$"/>
<!-- This regex matches lunchtime 12:00 to 12:59 -->
<condition field="${strftime(%H%M)}" expression="^(12[0-5][0-9])$">
<action application="set" data="business=lunch"/>
<action application="transfer" data="IVR_Closed"/>
<anti-action application="set" data="business=afternoon"/>
<anti-action application="transfer" data="IVR_Afternoon"/>
</condition>
</extension>
<extension name="Play Afternoon IVR">
<condition field="destination_number" expression="^IVR_Afternoon$"/>
<!-- This regex matches 1pm to 5:30pm -->
<condition field="${strftime(%H%M)}" expression="^((1[3-6])[0-5][0-9]|17[0-2][0-9])$">
<action application="set" data="business=afternoon"/>
<action application="transfer" data="IVR_Open"/>
<action application="set" data="business=closed"/>
<action application="transfer" data="IVR_Closed"/>
</condition>
</extension>
<extension name="Play Sat IVR">
<condition field="destination_number" expression="^IVR_Sat$"/>
<!-- First, match Sat; if not Sat then we're definitely closed -->
<condition field="${strftime(%w)}" expression="^([6])$">
<anti-action application="set" data="business=closed"/>
<anti-action application="transfer" data="IVR_Closed"/>
</condition>
<!-- Next, check time of day. First regex is to match 8:00am to 11:59am -->
<condition field="${strftime(%H%M)}" expression="^(((08|09|1[0-1])[0-5][0-9]))$">
<action application="set" data="business=morning"/>
<action application="transfer" data="IVR_Open"/>
<action application="set" data="business=closed"/>
<action application="transfer" data="IVR_Closed"/>
</condition>
</extension>
<extension name="Play open IVR">
<condition field="destination_number" expression="^IVR_Open$">
<action application="lua" data="ivr-business-open.lua"/> <!-- your "open" Lua script here -->
</condition>
</extension>
<extension name="Play closed IVR">
<condition field="destination_number" expression="^IVR_Closed$">
<action application="lua" data="ivr-business-closed.lua"/> <!-- your "closed" Lua script here -->
</condition>
</extension>