[asterisk-users] GotoIftime
Tilghman Lesher
tilghman at mail.jeffandtilghman.com
Wed Jul 30 17:05:38 CDT 2008
On Wednesday 30 July 2008 16:19:52 John Millican wrote:
> Ira wrote:
> > At 01:36 PM 7/30/2008, you wrote:
> >> Nhadie wrote:
> >>> Hi
> >>>
> >>> How cn i define in GotoIfTime from day 1 extending to day 2?
> >>>
> >>> e.g July 30 2200 up to July 31 0200
> >>>
> >>> I'm thinking like this: GotoIfTime(22:00-02:00|*|30-31|jul?test,s,1)
> >>
> >> GotoIfTime(22:00-23:59|*|30-31|jul?test,s,1)
> >> GotoIfTime(00:00-02:00|*|30-31|jul?test,s,1)
> >
> > Does that leave a 1 minute or 1 second hole?
>
> Should be neither. Since the time frame allowed is in minutes there is
> no time between 23:59 and 00:00 Since it has to be one or the other.
> Now, if I "assume" that the time is converted from time_t to 24 hour
> format using something such as localtime or gmtime the result of this
> should be using only tm_min and tm_hour which would also mean there is
> no hole.
Actually, the timeframe is in intervals of 2 minutes, so he could have put
23:58, and it would have worked the same. The time is, in fact, set up into
a bitfield, each bit representing a period of 2 minutes. If the current time
maps into the bitfield to a location which is set, then the time matches.
For the original question, note that the days of months, months, days of the
week, and time are all checked independently, such that if any part fails its
respective test, the whole thing fails.
So even though *|*|30|* would specify an invalid date in February, it doesn't
matter, as the algorithm would never find a 30th day in February, and so it
would fail.
Also note that GotoIfTime is unlike cron, whose algorithm for checking a
match is:
MINUTES and HOUR and ( ( DAY and MONTH ) or WEEKDAY )
the matching for GotoIfTime is:
TIME and DAY and MONTH and WEEKDAY
> THESE ARE ALL ASSUMPTIONS, I have not checked the code.
I helped write the code, and you are (mostly) correct. I just checked the
code, just to be sure.
--
Tilghman
More information about the asterisk-users
mailing list