thanks for the detailed explanation :)

so what i make of this is if u use a wrap around time or u want full 24 hours either in same day or across days then u need to set one second lower so "5:00-5:00" should actually be "5:00:00-4:59:59" which would be 5am from today to 4:59:59am tomorrow and same goes for "00:00:00-00:00:00" which should be "00:00:00-23:59:59"

now same if u combine with wday then again u need to specify a second lower in the max time for it to work properly if the start and end time is set same or it will read it as 0


Regards,
Bipin



-------- Original Message --------
Subject: Re: [Freeswitch-users] week day and time condition possible bug
From: Ken Rice <krice@freeswitch.org>
To: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org>
Date: 9/4/2016, 7:14:25 PM
Ok lets try to make sense of this.

The time-of-day matching in your initial email
>>       <condition wday="1-2" time-of-day="00:00:00-00:00:00" break="never">

happens in 2 stages... stage 1) does wday fall in the range of 1-2
wday="1-2"
wdaymin = 1
wdayamx = 2
so does if (today >= wday-min || today <= wday-max).... if you set this for 0-0 or 1-1 then only day 0 or only day 1 would match. Now the above example is simplified psuedo code just for the sake of explanation...

The time-of-day matching works similarly... after the value for the time of day field is parsed the following if statement (actually taken from the code) happens

if (range_start <= range_end ? (val >= range_start && val <= range_end) : (val >= range_start || val <= range_end)) { ... }

so this allos for the range_end to be a lower value... however the same thing happens does the current time val fall in the range of times... so if you set the start and the end time to 00:00:00 the only time it will match is 00:00:00. lets reduce this for the sake of simplicity from the long date to just seconds of the day... 00:00:00 == second 0 for the day... so


range start is <= range_end (in fact its 0) so ... we'll do the true half of the expression?true:false statement there...
if (val >= range_start && val <= range_end)  where val is the current number of seconds into today...

so you have told it that the only range that can match is 0 thru 0 inclusive... how can any other time match...

so in your example there are only 2 times that will match 00:00:00 on day 1 and 00:00:00 on day 2...

the proper way to include an entire day is 00:00:00-23:59:59 which covers all possible seconds in a range