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
27
Quintiq file version 2.0
#parent: #root
StaticMethod CalculateEndTime (
  TimeZone timezone_i,
  Date startDate_i,
  Duration startTimeOfDay_i,
  Duration duration_i
) const declarative remote as DateTime
{
  Description:
  [*
    Calculate the EndTime based on the provided Timezone, StartDate, StartTimeOfDay and Duration.
    Daylight Saving Time (DST) is taken into account when applicable.
  *]
  TextBody:
  [*
    // Calculate the number of days between start and end, and the EndTimeOfDay.
    nrOfDays     := ( startTimeOfDay_i + duration_i ) div Duration::Hours( 24 );
    endTimeOfDay := ( startTimeOfDay_i + duration_i ) mod Duration::Hours( 24 );
    
    // Use AddAsPeriod() to take Daylight Saving Time into account.
    endTime := ( startDate_i + nrOfDays ).DateTime( timezone_i ).AddAsPeriod( timezone_i, endTimeOfDay );
    
    return endTime;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}