tmassey@obscorp.com
2005-Oct-21 08:51 UTC
[Asterisk-Users] Definitive answer: time-range includes
Hello! I have a question regarding time-based includes in the dialplan. How are boundary conditions handled? And is there a definitive, documented procedure for how to handle overlapping time includes? For example, if I want to have day/night service from 8 A.M. to 5 P.M., there are two ways I can do it: No overlapping times: [PSTN] include => PSTN-Nighttime|17:00-7:59|mon-fri|*|* include => PSTN-Daytime|8:00-16:59|mon-fri|*|* include => PSTN-Nighttime|*|sat-sun|*|* On this one, no time has more than one valid time entry associated with it. Each entry ends the previous minute to the next one starting. This is the correct one to use iff Asterisk matches the time to the includes inclusive of both the start and end time. However, if Asterisk is *not* inclusive of, say, the end time, you will end up with one-minute holes at the boundaries. Overlapping time: [PSTN] include => PSTN-Nighttime|17:00-8:00|mon-fri|*|* include => PSTN-Daytime|8:00-17:00|mon-fri|*|* include => PSTN-Nighttime|*|sat-sun|*|* On this one, there are two times that have more than one valid time entry associated with it: One minute at each of 8:00 A.M. and 5:00 P.M. Each entry overlaps the other. This is the correct one to use iff Asterisk matches the time to the includes inclusive of the start time but *exclusive* of the end time (or vice-versa) However, if this is not the case, you will end up with one-minute overlaps at the boundaries. The following link in the Wiki describes how to use Asterisk's time-based includes, and even includes overlapping time entries, but does not document these corner-cases: http://www.voip-info.org/wiki/index.php?page=Asterisk+tips+openhours Does anyone know the difinitive anser to how Asterisk matches time ranges? A difinitive, precise statement of what happens with overlapping includes would be nice. Given the right answer, it would allow nice and easy holiday nighttime includes: include => PSTN-Nighttime|*|*|25|dec ; Night on Christmas include => PSTN-Nighttime|*|sat-sun|*|* ; Night on weekends include => PSTN-Nighttime|17:05-7:55|mon-fri|*|* ; Night on evenings include => PSTN-Daytime|*|*|*|* ; Default: Handle as daytime Even a simple order-based priority would be great: whichever time entry matches *first* (or last) would work well. In fact, it may even already work that way. I just don't see anything describing how boundaries and overlaps are handled. I'm also not sure that that final entry will work as an "include only if there is no other time entry matching". I would hope so. You can't use an include *without* time matching, otherwise it would always be included and would mess things up. Does anyone know the answer to this? Tim Massey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20051021/cdffe0c2/attachment.htm