I am working on a class scheduler, and I am having trouble figuring out how to solve the problems of deciding if a class is conflicting with one another.
Say I have 2 classes
Class 1 runs from 14:00 to 15:15
Class 2 runs from 15:00 to 15:50
Those class times are definately overlapping. Can anybody help me figure out how to tell if they are over lapping?
Here's another set of test data that is eluding me:
Class 1 runs from 18:00 to 21:00
Class 2 runs from 19:00 to 19:50
If anybody could help me out, that would be really great and much appreciated =)
-Pat
How To Find Time Conflicts
Moderator: General Moderators
A simpe test would be
Hope this helps
Code: Select all
if (Class1EndTime > Class2StartTime)
{
you have a clash
}Re: How To Find Time Conflicts
The solution depends on two things:pmcnally wrote:I am working on a class scheduler, and I am having trouble figuring out how to solve the problems of deciding if a class is conflicting with one another.
- How do you store the data (database, php arrays, something else)?
- Do you need to check for overlapping for just one class (i.e. when class is added you run the check if it would fit in schedule) or you would got entire schedule somehow and then check if it has any overlapping classes?