Calendar Class

Represents a calendar used in a project.
Inheritance Hierarchy
SystemObject
  Aspose.TasksCalendar

Namespace:  Aspose.Tasks
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.5
Syntax
public class Calendar

The Calendar type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleBaseCalendar
Gets or sets the base calendar on which this calendar depends. Only applicable if the calendar is not a base calendar. Read/write Calendar.
Public propertyCode exampleExceptions
Gets CalendarExceptionCollection object. The collection of exceptions that is associated with the calendar.
Public propertyCode exampleIsBaseCalendar
Gets a value indicating whether the calendar is a base calendar. Read-only Boolean.
Public propertyCode exampleIsBaselineCalendar
Gets or sets a value indicating whether the calendar is a baseline calendar. Read/write Boolean.
Public propertyCode exampleName
Gets or sets the name of the calendar. Read/write String.
Public propertyCode exampleParentProject
Gets parent project for this calendar.
Public propertyCode exampleUid
Gets or sets the unique identifier of the calendar. Read/write Int32.
Public propertyCode exampleWeekDays
Gets WeekDaysCollection for this calendar. The collection of weekdays that defines the calendar.
Public propertyCode exampleWorkWeeks
Gets WorkWeekCollections object. The collection of work weeks that is associated with the calendar.
Methods
  NameDescription
Public methodCode exampleDelete
Removes calendar from project.
Public methodCode exampleEquals
Returns a value indicating whether this instance is equal to a specified object.
(Overrides ObjectEquals(Object).)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetFinishDateByStartAndWork(DateTime, Duration)
Calculates the date when the specified amount of work time will pass according to the calendar.
Public methodCode exampleGetFinishDateByStartAndWork(DateTime, TimeSpan)
Calculates the date when the specified amount of work time will pass according to the calendar.
Public methodCode exampleGetHashCode
Returns a hash code for the instance of the Calendar class.
(Overrides ObjectGetHashCode.)
Public methodCode exampleGetNextWorkingDayStart
Calculates next working day start from the date.
Public methodCode exampleGetPreviousWorkingDayEnd
Calculates previous working date end from the specified date.
Public methodCode exampleGetStartDateFromFinishAndDuration(DateTime, Duration)
Returns StartDate based on specified FinishDate and Duration.
Public methodCode exampleGetStartDateFromFinishAndDuration(DateTime, TimeSpan)
Returns StartDate based on specified FinishDate and Duration.
Public methodCode exampleGetTaskFinishDateFromDuration
Calculates the task finish date and time from its start date, split parts and the duration.
Public methodGetType (Inherited from Object.)
Public methodCode exampleGetWorkingHours(DateTime)
Returns amount of working hours at the date.
Public methodCode exampleGetWorkingHours(DateTime, DateTime)
Return working hours for the specified dates.
Public methodCode exampleGetWorkingTimes
Returns WorkingTimeCollection of working times.
Public methodCode exampleIsDayWorking
Determines whether the day is working day.
Public methodStatic memberCode exampleMake24HourCalendar
Makes a given Calendar to be a 24Hour Calendar. 24Hours Calendar is a Calendar in which every day of week is working with Round-the-clock working hours.
Public methodStatic memberCode exampleMakeNightShiftCalendar
Makes a given Calendar as Night Shift Calendar.
Public methodStatic memberCode exampleMakeStandardCalendar
Creates default standard calendar.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Remarks
Calendars are used to define standard working and non-working times. Projects must have one base calendar. Tasks and resources can have their own non-base calendars that are based on a base calendar.
Examples
How to create simple calendar from scratch.
[C#]
// create empty calendar
Calendar calendar = new Calendar("New calendar");
// adds default working days (8 working hours from 9:00 to 17:00)
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
// create new new working day
WeekDay myWeekDay = new WeekDay(DayType.Thursday);
// Sets working time. Only time part of DateTime is important
    WorkingTime wt1 = new WorkingTime();
    wt1.FromTime = new DateTime(1, 1, 1, 6, 0, 0, 0);
    wt1.ToTime = new DateTime(1, 1, 1, 12, 0, 0, 0);
    WorkingTime wt2 = new WorkingTime();
    wt2.FromTime = new DateTime(1, 1, 1, 14, 0, 0, 0);
    wt2.ToTime = new DateTime(1, 1, 1, 18, 0, 0, 0);
    myWeekDay.WorkingTimes.Add(wt1);
    myWeekDay.WorkingTimes.Add(wt2);
    myWeekDay.DayWorking = true;
calendar.Days.Add(myWeekDay);
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday));
// adds weekend
calendar.Days.Add(new WeekDay(DayType.Saturday));
calendar.Days.Add(new WeekDay(DayType.Sunday));
[VB]
' create empty calendar
Dim calendar As Calendar =  New Calendar("New calendar")
' adds default working days (8 working hours from 9:00 to 17:00)
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday))
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday))
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday))
' create new new working day
Dim myWeekDay As WeekDay =  New WeekDay(DayType.Thursday)
' Sets working time. Only time part of DateTime is important
    Dim wt1 As WorkingTime =  New WorkingTime()
    wt1.FromTime = New DateTime(1, 1, 1, 6, 0, 0, 0)
    wt1.ToTime = New DateTime(1, 1, 1, 12, 0, 0, 0)
    Dim wt2 As WorkingTime =  New WorkingTime()
    wt2.FromTime = New DateTime(1, 1, 1, 14, 0, 0, 0)
    wt2.ToTime = New DateTime(1, 1, 1, 18, 0, 0, 0)
    myWeekDay.WorkingTimes.Add(wt1)
    myWeekDay.WorkingTimes.Add(wt2)
    myWeekDay.DayWorking = True
calendar.Days.Add(myWeekDay)
calendar.Days.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday))
' adds weekend
calendar.Days.Add(New WeekDay(DayType.Saturday))
calendar.Days.Add(New WeekDay(DayType.Sunday))
Examples
Shows how to define a new calendar, add week days to it and define working times for days.
var project = new Project();

// Define a calendar
var calendar = project.Calendars.Add("Calendar1");

// Add working days monday through thursday with default timings
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday));
calendar.WeekDays.Add(new WeekDay(DayType.Saturday));
calendar.WeekDays.Add(new WeekDay(DayType.Sunday));

// Set friday as short working day
var weekDay = new WeekDay(DayType.Friday);

// Sets working time. Only time part of DateTime is important
var workingTime = new WorkingTime();
workingTime.FromTime = new DateTime(1, 1, 1, 9, 0, 0, 0);
workingTime.ToTime = new DateTime(1, 1, 1, 12, 0, 0, 0);
var workingTime2 = new WorkingTime();
workingTime2.FromTime = new DateTime(1, 1, 1, 13, 0, 0, 0);
workingTime2.ToTime = new DateTime(1, 1, 1, 16, 0, 0, 0);
weekDay.WorkingTimes.Add(workingTime);
weekDay.WorkingTimes.Add(workingTime2);
weekDay.DayWorking = true;
calendar.WeekDays.Add(weekDay);

// working with the project...
See Also