[prev in list] [next in list] [prev in thread] [next in thread] 

List:       asterisk-users
Subject:    Re: [asterisk-users] GotoIftime
From:       Tilghman Lesher <tilghman () mail ! jeffandtilghman ! com>
Date:       2008-07-30 22:05:38
Message-ID: 200807301705.38542.tilghman () mail ! jeffandtilghman ! com
[Download RAW message or body]

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

_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

AstriCon 2008 - September 22 - 25 Phoenix, Arizona
Register Now: http://www.astricon.net

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic