public boolean isTimeslotFreeForRoom(Room r, Calendar time, int hours) {
   Calendar endTime = (Calendar) time.clone();
   endTime.add(Calendar.HOUR_OF_DAY, hours);
   for (WeeklyEvent we : r.getWeeklyEvents()) {
     if (DateFunctions.doDateRangesOverlap(
         time, endTime, we.getStartTime(), we.getEndTime(), true)) {
       return false;
     }
   }
   return true;
 }
 public boolean isTimeslotFreeForCourse(Course c, Calendar time, int hours) {
   List<Room> rooms = findRoomsForCourse(c);
   Calendar end = (Calendar) time.clone();
   end.add(Calendar.HOUR_OF_DAY, hours);
   for (CurriculumSemester cs : c.getCurriculumSemesters()) {
     for (Course co : cs.getCourses()) {
       WeeklyEvent we = co.getWeeklyEvent();
       if (we != null
           && DateFunctions.doDateRangesOverlap(
               time, end, we.getStartTime(), we.getEndTime(), true)) {
         return false;
       }
     }
   }
   return true;
 }