| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GenerateColumn ( | 
|   Dates periods, | 
|   String timeunit, | 
|   Date starttime, | 
|   Date endtime | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // 甄兰鸽 Jun-25-2024 (created) | 
|     mindate               := min( periods, Elements, period, period ); | 
|     maxdate               := max( periods, Elements, period, period ); | 
|     //查询日期返回需要在计划日期之内 | 
|     if( starttime < mindate and endtime > maxdate ){ | 
|       if( starttime < mindate ){ | 
|         starttime             := mindate; | 
|       } | 
|       if( endtime > maxdate ){ | 
|         endtime               := maxdate; | 
|       } | 
|       if( timeunit = Translations::MP_GlobalParameters_Day() ){ | 
|         for( start := starttime; start <= endtime; start := start.DateTime().StartOfNextDay().Date() ){ | 
|           periodname          := start.Format( "M2/D2/Y" ); | 
|           if( not exists( this, Column, column, column.StartDate() = start ) ){ | 
|             this.Column( relnew, ColumnName := periodname, StartDate := start, EndDate := start, TimeUnit := Translations::MP_GlobalParameters_Day() ); | 
|           } | 
|         } | 
|       }else if( timeunit = Translations::MP_GlobalParameters_Week() ){ | 
|     //    weekstartstr          := ' KW'; | 
|         for( start := starttime; start <= endtime; start := start.StartOfNextWeek() ){ | 
|           weekend             := ( start.StartOfNextWeek() - Duration::Days( 1 ) ).Date();//.Concat( weekstartstr.Concat( weekend.Week().Format( 'N(LPad0(2))' ) ) ) | 
|            | 
|           this.Column( relnew, ColumnName := weekend.Format( "M2/D2/Y" ), StartDate := start, EndDate := weekend, TimeUnit := Translations::MP_GlobalParameters_Week() ); | 
|         } | 
|       }else if( timeunit = Translations::MP_GlobalParameters_Month() ){ | 
|         for( start := starttime; start <= endtime; start := start.StartOfNextMonth() ){ | 
|           monthend            := ( start.StartOfNextMonth() - Duration::Days( 1 ) ).Date();//.Concat( ' ' ).Concat( monthend.Format( "MM", us_locale ).Concat( '/').Concat( [String]monthend.Month() ).Concat( '月' ) ) | 
|     //      us_locale := Locale::Construct( 'en_us' ); | 
|           this.Column( relnew, ColumnName := monthend.Format( "M2/D2/Y" ), StartDate := start, EndDate := monthend, TimeUnit := Translations::MP_GlobalParameters_Month() ); | 
|         } | 
|       } | 
|     } | 
|     //weekstart             := periods.Element( 0 ); | 
|     //monthstart            := periods.Element( 0 ); | 
|     //traverse( periods, Elements, periodtime ){ | 
|     //  periodname          := periodtime.Format( "M2/D2/Y" ); | 
|     //   | 
|     //  this.Column( relnew, Name := periodname, StartDate := periodtime, EndDate := periodtime, TimeUnit := Translations::MP_GlobalParameters_Day() ); | 
|     //   | 
|     //  if( periodtime = weekstart ){ | 
|     //    weekperiodname    := weekstart.Format( "M2/D2/Y" ); | 
|     //    this.Column( relnew, Name := weekperiodname, StartDate := weekstart, EndDate := ( weekstart + Duration::Days( 6 ) ).Date(), TimeUnit := Translations::MP_GlobalParameters_Week() ); | 
|     //    weekstart         := ( weekstart + Duration::Days( 7 ) ).Date(); | 
|     //  } | 
|     //  if( periodtime = monthstart ){ | 
|     //    monthperiodname   := monthstart.Format( "M2/D2/Y" ); | 
|     //    enddate           := ( monthstart.StartOfNextMonth() - Duration::Days( 1 ) ).Date(); | 
|     //    this.Column( relnew, Name := monthperiodname, StartDate := monthstart, EndDate := enddate, TimeUnit := Translations::MP_GlobalParameters_Month() ); | 
|     //    monthstart        := monthstart.StartOfNextMonth(); | 
|     //  } | 
|     //} | 
|   *] | 
| } |