View Single Post
Old 07-15-09, 09:17 AM   #6
ViN86
 
Join Date: Mar 2004
Posts: 15,486
Default Re: Timetable in MySQL

Quote:
Originally Posted by Tuork View Post
Well, let's say Tutor Andy has the following free period: Mondays, 1:00pm - 2:30pm.

Now let's say that little Billy wants Maths classes on Monday, from 1:00pm to 2:00pm.

I'd look up free time periods that match Billy's requirements, which would give me Andy's free period. The problem here is that the time periods don't match exactly, so I would need some way to re-define Andy's free period so that it no longer presents the initial hour. I'd have to mess with time differences, etc, which would make the algorithmic a tad more complicated than if, say, I used 30 minute periods all the time.

Does that make any sense?
Sure, but you don't expect to have more than 12 hour shifts right? So a simple function to subtract the times should be pretty easy.

EDIT: You could also try storing all start/end times as the number of seconds. Then a subtraction would be easy and converting back to the time could be done with a simple function as well.
ViN86 is offline   Reply With Quote