Lai,Risheng
2023-11-02 30c02e0c981b16be0918483543f4b812956c45d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Quintiq file version 2.0
#parent: #root
Method GetWeekOfMonthAndDayOfWeek (
  Date date_i,
  output String weekOfMonth_o,
  output String dayOfWeek_o
) id:Method_LibCal_dlgEvent_GetWeekOfMonthAndDayOfWeek
{
  #keys: '[131094.0.1707226619]'
  Body:
  [*
    // This logic is used by both "Monthly" and "Yearly".
    
    // Determine the occurrence of the day (i.e. the week) within the month.
    occurrenceOfDay := ( date_i.Day() - 1 ) div 7;
    
    weeks         := Translations::Pattern_WeekOfMonth().Tokenize( ssMonthlyPatternWeekOfMonth.RowSeparator() );
    weekOfMonth_o := weeks.Element( occurrenceOfDay );
    
    // Determine the day of the week.
    days        := Translations::Pattern_Days().Tokenize( ssMonthlyPatternDayOfWeek.RowSeparator() );
    dayOfWeek_o := days.Element( date_i.DayOfWeek() - 1 );
  *]
}