admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Quintiq file version 2.0
#parent: #root
Method SetDuration (
  Duration duration_i
) as LibCal_Event
{
  Description: 'Set the duration of the event.'
  TextBody:
  [*
    // Ignore seconds.
    duration := duration_i.Round( Duration::Minutes( 1 ) );
    
    // Use a FeedbackObject the collect the validation feedback.
    feedback := LibCal_Validate::FeedbackObject();
    
    moreInfo := this.GetEventInfo() + ", Duration = " + duration_i.Format( Translations::DurationFormat() );
    LibCal_Validate::RegisterError( LibCal_Validate::Event_Duration( duration ), moreInfo );
    
    // Process the feedback that has been registered by the validation (if any).
    LibCal_Util::ProcessFeedbackObject( feedback );
    
    // The below is only executed when no validation errors were encountered.
    leadPart := this.LeadingParticipation();
    if( not isnull( leadPart ) )
    {
      isAllDay := this.IsAllDay();
      
      if( this.Duration() <> duration )
      {
        this.IsChanged( true );
      }
    
      // Set the Duration and the EndTimeOfDay of the Event...
      this.Duration( duration );
      
      endTimeOfDay := ( this.StartTimeOfDay() + duration ) mod Duration::Hours( 24 );
      this.EndTimeOfDay( endTimeOfDay );
      
      // ...and the EndDate of the LeadingParticicpation.
      endDate := leadPart.StartDate() + ( ( this.StartTimeOfDay() + duration ) div Duration::Hours( 24 ) );
      leadPart.Update( leadPart.StartDate(), endDate );
      
      // Validate the resulting StartTime and EndTime.
      leadPart.CalcStartTime();
      leadPart.CalcEndTime();
      
      startTime := leadPart.StartTime();
      endTime   := leadPart.EndTime();
      timezone  := this.Calendar().GetTimeZone();
      convOps   := ConversionOptions::ISO()
      moreInfo  := this.GetEventInfo() + ", StartTime = " + startTime.Format( Translations::DateTimeFormat(), convOps )
                                       + ", EndTime = "   + endTime  .Format( Translations::DateTimeFormat(), convOps );
      LibCal_Validate::RegisterError( LibCal_Validate::Event_StartTime_EndTime( startTime, endTime ), moreInfo );
    
      // See if isAllDay was and still is applicable.  
      isAllDay := isAllDay
              and startTime.TimeOfDay( timezone ) = Duration::Zero()
              and endTime.TimeOfDay( timezone )   = Duration::Zero()
              and duration                        > Duration::Zero();
      
      // Process the feedback that has been registered by the validation (if any).
      LibCal_Util::ProcessFeedbackObject( feedback );
      
      // The below is only executed when no validation errors were encountered.
      this.IsAllDay( isAllDay );
    }
    
    // Make the API fluent.
    return this;
  *]
}