chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
Method UpdateDuration () id:Method_LibCal_dlgEvent_UpdateDuration
{
  #keys: '[131092.0.2119796120]'
  Body:
  [*
    // Calculate the duration based on the values of the date- and time-controls.
    timezone := TimeZone::UTCTimeZone();  // Use the UTC-timezone here, don't correct for a specific timezone.
    duration := dhDuration.Data();
    
    if( dsStartDate.Date().IsFinite() and durStartTimeOfDay.Duration().IsFinite() and
        dsEndDate  .Date().IsFinite() and durEndTimeOfDay  .Duration().IsFinite() )
    {
      // Don't use AddAsPeriod here, the 'nett' duration should be calculated here.
      start := dsStartDate.Date().Add( timezone, durStartTimeOfDay.Duration() );
      end   := dsEndDate  .Date().Add( timezone, durEndTimeOfDay  .Duration() );
        
      duration := end - start;
    }
    
    // Update the DataHolder, which will update the labels that show the duration (when not in days only mode).
    dhDuration.Data( duration );
  *]
}