lazhen
2024-11-05 aa42b48fd2d23e75b64a0aec05d5be4b9ebf0465
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Quintiq file version 2.0
#parent: #root
Method GenerateColumn (
  Dates periods
)
{
  TextBody:
  [*
    // 甄兰鸽 Jun-25-2024 (created) 
    weekstart             := periods.Element( 0 );
    
    monthstart            := periods.Element( 0 );
    traverse( periods, Elements, periodtime ){
      periodname          := periodtime.Format( "M2/D2/Y" );
      
      this.Column( relnew, ColumnName := periodname, StartDate := periodtime, EndDate := periodtime, TimeUnit := Translations::MP_GlobalParameters_Day() );
      
      weekend             := ( weekstart + Duration::Days( 6 ) ).Date();
      if( ( weekend.Year() <> periodtime.Year() and weekend.Month() > 1 ) or ( abs( weekstart.Week() - periodtime.Week() ) > 1 and weekend.Year() = periodtime.Year() ) ){
        weekstart         := periodtime;
      }
      if( periodtime = weekstart ){
        weekperiodname    := weekstart.Format( "M2/D2/Y" );
        this.Column( relnew, ColumnName := weekperiodname, StartDate := weekstart, EndDate := ( weekstart.StartOfNextWeek() - Duration::Days( 1 ) ).Date(), TimeUnit := Translations::MP_GlobalParameters_Week() );
        
      }
      if( ( monthstart.Year() <> periodtime.Year() and abs( monthstart.Month() - periodtime.Month() ) <> 11 ) or ( abs( monthstart.Month() - periodtime.Month() ) > 1 and monthstart.Year() = periodtime.Year() ) ){
        monthstart        := periodtime;
      }
      if( periodtime = monthstart ){
        monthperiodname   := monthstart.Format( "M2/D2/Y" );
        enddate           := ( monthstart.StartOfNextMonth() - Duration::Days( 1 ) ).Date();
        this.Column( relnew, ColumnName := monthperiodname, StartDate := monthstart, EndDate := enddate, TimeUnit := Translations::MP_GlobalParameters_Month() );
        
      }
      weekstart         := periodtime.StartOfNextWeek();
      monthstart        := periodtime.StartOfNextMonth();
    }
  *]
}