Skip to main content

TdxGanttControlCalendarWeekDay.CreateTimePeriod Method

Adds a custom time interval to a calendar.

Declaration

procedure CreateTimePeriod;

Remarks

Call this procedure to add a time period (in days) in which a day’s settings (for instance, day type, working times, and so on) are in effect. You should specify the start and finish for each time period.

The code example below shows how to convert Monday to a one-day weekend and Saturday to a half-day workday:

uses
// Contains calendar-related API declaration
..., dxGanttControlCalendars
var
  ADay: TdxGanttControlCalendarWeekDay;
  AWorkTime: TdxGanttControlCalendarWeekDayWorkTime;
begin
  // Adds a day to a calendar's collection of days  
  ADay := dxGanttControl1.DataModel.Calendars[0].WeekDays.Append;
  // Creates a custom time period for the day
  ADay.CreateTimePeriod;
  // Specifies the custom time period's start date
  ADay.TimePeriod.FromDate := EncodeDate(2021, 6, 7);
  // Specifies the custom time period's finish date
  ADay.TimePeriod.ToDate := ADay.TimePeriod.FromDate + 1;
  // Converts the day to the day with a custom schedule
  ADay.DayType := TdxGanttControlWeekDayType.Exception;
  // Specifies that the day is non-working day
  ADay.Workday := False;
  ADay := dxGanttControl1.DataModel.Calendars[0].WeekDays.Append;
  ADay.CreateTimePeriod;
  ADay.TimePeriod.FromDate := EncodeDate(2021, 6, 12);
  ADay.TimePeriod.ToDate := ADay.TimePeriod.FromDate + 1;
  ADay.DayType := TdxGanttControlWeekDayType.Exception;
  // Specifies that the day is a work day
  ADay.Workday := True;
  // Populates a worktime collection with the day's work time 
  AWorkTime := ADay.WorkTimes.Append;
  // Specifies the work time's start
  AWorkTime.FromTime := EncodeTime(8, 0, 0, 0);
  // Specifies the work time's finish
  AWorkTime.ToTime := EncodeTime(12, 0, 0, 0);
end;

Note

A day exception has no effect if it has no specified start and finish.

See Also