Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method GetRoundedMinimumShiftPatternDuration ( 
 | 
  Real minimumduration 
 | 
) const as Real 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Rounds up the given minimum duration in order to ensure that shift patterns are used until the end of the unit period that ends after 'minimumduration' is elapsed. 
 | 
    For example: if the shift pattern starts in January, and the minimum duration is 61 days: round up the RHS to 31+28+31=90 days, to make sure that all 3 months are using the shift pattern.  
 | 
    Otherwise, January+March would be a valid solution because 31+31=62 (>61). 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    result := 0.0; 
 | 
    nextperiod := this; 
 | 
     
 | 
    while( result < minimumduration and not isnull( nextperiod ) ) 
 | 
    { 
 | 
      result := result + nextperiod.Duration().HoursAsReal(); 
 | 
      nextperiod := guard( nextperiod.NextPlanningUnitPeriod().astype( UnitPeriodTime ), null( UnitPeriodTime ) ); 
 | 
    } 
 | 
     
 | 
    // If the period is too close to the end of the horizon, we can't round up. 
 | 
    result := maxvalue( result, minimumduration ); 
 | 
     
 | 
    return result; 
 | 
  *] 
 | 
} 
 |