src/core/resource-manager.js
function tryReservation(schedules, min,max) {
    var reservation = {success: false},
        resources = [], start, end;

    for(var i = 0, len = schedules.length; i < len; i++) {
      var schedule = schedules[i],
          range = schedule.range;

      if(!isInternal(schedule)) {
        resources.push(schedule.id);
      }

      start = !start || range[0] > start ? range[0] : start;
      end = !end || range[1] < end ? range[1] : end;
    }

    var duration = (end - start) / later.MIN;
    if(duration >= min || duration >= max) {
      duration = max && duration > max ? max : duration;
      reservation = createReservation(resources, start, duration);
    }

    return reservation;
  }
function tryReservation(schedules, min,max) {
    var reservation = {success: false},
        resources = [], start, end;

    for(var i = 0, len = schedules.length; i < len; i++) {
      var schedule = schedules[i],
          range = schedule.range;

      if(!isInternal(schedule)) {
        resources.push(schedule.id);
      }

      start = !start || range[0] > start ? range[0] : start;
      end = !end || range[1] < end ? range[1] : end;
    }

    var duration = (end - start) / later.MIN;
    if(duration >= min || duration >= max) {
      duration = max && duration > max ? max : duration;
      reservation = createReservation(resources, start, duration);
    }

    return reservation;
  }
function tryReservation ( schedules , min , max ) { var reservation = { success : false } , resources = [ ] , start , end ; for ( var i = 0 , len = schedules . length ; i < len ; i ++ ) { var schedule = schedules [ i ] , range = schedule . range ; if ( ! isInternal ( schedule ) ) { resources . push ( schedule . id ) ; } start = ! start || range [ 0 ] > start ? range [ 0 ] : start ; end = ! end || range [ 1 ] < end ? range [ 1 ] : end ; } var duration = ( end - start ) / later . MIN ; if ( duration >= min || duration >= max ) { duration = max && duration > max ? max : duration ; reservation = createReservation ( resources , start , duration ) ; } return reservation ; }
Determines if the current schedules overlap for at least min minutes. If
they do, a reservation is created, otherwise a failure is reported.
Determines if the current schedules overlap for at least min minutes . If they do a reservation is created otherwise a failure is reported .