Clearly, I'm going to have to get on the PHP short bus.  I was never any
good at bitmasking.

In the meantime, I've got it working.  Not elegant, mind you, but working
nonetheless.  Thanks.

Bob

----- Original Message ----- 
From: "Manuel Vázquez Acosta" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 16, 2004 9:47 PM
Subject: [PHP] Re: Algorithm....


> I suggest a bit's mask technique; since max(i)=96, you can represent a day
> by 96/8 = 12 bytes = 3 (32-bits integers).
>
> TimeFrameA is an integer representing the first 32 15-minutes
chunks(0-31),
> TimeFrameB represents 32-63, and TimeFrameC 64-95.
>
> If a bit is 1 the you that 15-minutes chunk is marked as "busy", 0
> otherwise. It is easy to find which is the first 'busy'bit in each
> TimeFrame:
>     // at least one bit is marked as busy
>     if (TimeFrame <> 0)
>     {
>         mask = 0x80000000;
>         while (mask & TimeFrame == 0)
>             mask = mask >> 1;
>     }
>
> Hope this helps (I think it saves both memory and time)
>
> Manu.
>
>
> "Bob Eldred" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I'm working on a calendaring script right now, and am stuck on a
> > programmatic way to figure something out.
> >
> > Basically, the work day is broken down into 15-minute intervals, where
the
> > value of a given interval can be figured as $hour=floor($i/4) and the
> > minutes can be figured as $minutes=($i%4)*15.  So 32 = 8:00, 33=8:15,
etc.
> >
> > Currently, it's relatively easy to pull up a day, and block out those
> times
> > that are already taken up with appointments.  I'm throwing them all into
> an
> > array ($available_times).  So, that array would look like:
> >
> > 32=>yes
> > 33=>yes
> > 34=>yes
> > 35=>yes
> > 36=>no
> > 37=>no
> > 38=>yes
> > 39=>yes
> >
> > etc, for someone who has a meeting from 9:00 to 9:30.
> >
> > Now, what I'm trying to do is check when they schedule a new meeting so
> that
> > they don't overlap their times with something that's already taken up.
> So,
> > in the array given above, if they select 8:30 as the start time, I'd
like
> > them to be able to select 8:45 or 9:00 as the end time, but nothing
later
> > than that, as the time from 9:00 to 9:30 is already taken up.
> >
> > And I'm stuck trying to figure out an approach to this.  Preferably one
> that
> > I can throw into javascript so they can fix their errors before it ever
> hits
> > the server.
> >
> > Any help appreciated.
> >
> > Bob
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to