lazhen
2024-09-10 11e66e438e5affbba0a7cdb258fbad1ab54a7dd8
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
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, 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();
      }
    }
  *]
}