lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
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.2098819379]'
  Body:
  [*
    // This logic is used by both "Monthly" and "Yearly".
    
    rowSeparator := ";";  // ssMonthlyPatternWeekOfMonth.RowSeparator() in not possible (yet?) in WC.
    
    // 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( rowSeparator );
    weekOfMonth_o := weeks.Element( occurrenceOfDay );
    
    // Determine the day of the week.
    days        := Translations::Pattern_Days().Tokenize( rowSeparator );
    dayOfWeek_o := days.Element( date_i.DayOfWeek() - 1 );
  *]
}