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
Quintiq file version 2.0
#parent: #root
Method UpdateStartAndEnd () id:Method_LibCal_dlgCalendarSettings_UpdateStartAndEnd
{
  #keys: '[131094.1.162996849]'
  Body:
  [*
    now      := DateTime::Now();
    base     := dtBase.DateTime();
    window   := [Number]edtWindow.Text();
    history  := [Number]edtHistory.Text();
    interval := durUpdateInterval.Duration();
    timezone := LibCal_GlobalState.GetLocalTimeZone();
    
    if( TimeZone::HasTimeZoneSupport() )
    {
      now  := now  + timezone.RawOffset();  // now and base are in GMT (?) and need to be adjusted
      base := base + timezone.RawOffset();  // in order to calculate the correct times to show in the dialog
    }
    
    start      := base;
    lastUpdate := base;
    
    if( now >= base and
        interval > Duration::Zero() )
    {
      if( base.IsInfinite() )
      {
        base := now.StartOfDay( timezone );
      }
      
      nrOfIntervalsSinceBase := ( now - base ) div interval;
      lastUpdate             := base + nrOfIntervalsSinceBase * interval;
    }
    
    start := lastUpdate - Duration::Days( history );
    end   := guard( start + Duration::Days( window ), DateTime::MinDateTime() );
    
    mask    := "D2-MM-Y  H2:m";
    convOps := ConversionOptions::ISO();
    
    lblStart.Text( start.Format( mask, convOps ) );
    lblEnd.Text(   end  .Format( mask, convOps ) );
    
    lblLastUpdate.Text( lastUpdate.Format( mask, convOps ) );
    
    nextUpdate := "-";
    if( interval > Duration::Zero() )
    {
      nextUpdate := ifexpr( base > now, base, lastUpdate + interval ).Format( mask, convOps );
    }
    lblNextUpdate.Text( nextUpdate );
  *]
}