Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod GetStartOfNextPeriod ( 
 | 
  DateTime datetime, 
 | 
  String timeunit, 
 | 
  Number nroftimeunit 
 | 
) const declarative remote as DateTime 
 | 
{ 
 | 
  Description: 'Return the end of the period given the date, time unit and nr of time unit' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // DWE2 Apr-25-2016 (modified) 
 | 
    value := datetime; 
 | 
     
 | 
    // Hour  
 | 
    if( timeunit = Translations::MP_GlobalParameters_Hour() ) 
 | 
    { 
 | 
      value := datetime + Duration::Hours( nroftimeunit ); 
 | 
    } 
 | 
    // Day 
 | 
    else if( timeunit = Translations::MP_GlobalParameters_Day() ) 
 | 
    { 
 | 
      value := datetime + Duration::Days( nroftimeunit ); 
 | 
    } 
 | 
    // Week 
 | 
    else if( timeunit = Translations::MP_GlobalParameters_Week() ) 
 | 
    { 
 | 
      value := value + Duration::Weeks( nroftimeunit ); 
 | 
    } 
 | 
    // Month 
 | 
    else if( timeunit = Translations::MP_GlobalParameters_Month() ) 
 | 
    { 
 | 
      value := PeriodSpecification_MP::GetStartOfNextMonth( value, nroftimeunit ); 
 | 
    } 
 | 
    // Quarter 
 | 
    else if( timeunit = Translations::MP_GlobalParameters_Quarter() ) 
 | 
    { 
 | 
      value := PeriodSpecification_MP::GetStartOfNextMonth( value, nroftimeunit * 3 ); // A quarter = 3 month 
 | 
    } 
 | 
    // Year 
 | 
    else if( timeunit = Translations::MP_GlobalParameters_Year() ) 
 | 
    { 
 | 
      value := PeriodSpecification_MP::GetStartOfNextMonth( value, nroftimeunit * 12 ); // One year = 12 months 
 | 
    } 
 | 
     
 | 
    return value; 
 | 
  *] 
 | 
} 
 |