Page 180 - Asterisk™: The Future of Telephony
P. 180
Time() looks at the current system time and uses that to decide whether or not to follow
a different branch in the dialplan.
The most obvious use of this application is to give your callers a different greeting before
and after normal business hours.
The syntax for the GotoIfTime() application looks like this:
GotoIfTime(times,days_of_week,days_of_month,months?label)
In short, GotoIfTime() sends the call to the specified label if the current date and time
match the criteria specified by times, days_of_week, days_of_month, and months. Let’s
look at each argument in more detail:
times
This is a list of one or more time ranges, in a 24-hour format. As an example, 9:00
A.M. through 5:00 P.M. would be specified as 09:00-17:00. The day starts at 0:00
and ends at 23:59.
It is worth noting that times will properly wrap around. So if you
wish to specify the times your office is closed, you might write
18:00-9:00 in the times parameter, and it will perform as expected.
Note that this technique works as well for the other components
of GotoIfTime. For example, you can write sat-sun to specify the
weekend days.
days_of_week
This is a list of one or more days of the week. The days should be specified as mon,
tue, wed, thu, fri, sat, and/or sun. Monday through Friday would be expressed as
mon-fri. Tuesday and Thursday would be expressed as tue&thu.
Note that you can specify a combination of ranges and single days,
as in: sun-mon&wed&fri-sat, or, more simply: wed&fri-mon.
days_of_month
This is a list of the numerical days of the month. Days are specified by the numbers
th
th
1 through 31. The 7 through the 12 would be expressed as 7-12, and the 15 th
th
and 30 of the month would be written as 15&30.
months
This is a list of one or more months of the year. The months should be written as
jan-apr for a range, and separated with ampersands when wanting to include non-
sequencial months, such as jan&mar&jun. You can also combine them like so:
jan-apr&jun&oct-dec.
152 | Chapter 6: More Dialplan Concepts