Aspose.Tasks for C++
Aspose::Tasks::Calendar Class Reference

Represents a calendar used in a project. More...

#include <Calendar.h>

Inherits Aspose::Tasks::ICalendar.

Public Member Functions

System::String get_Name () const
 Gets the name of the calendar. More...
 
void set_Name (const System::String &value)
 Sets the name of the calendar. More...
 
int32_t get_Uid () const
 Gets the unique identifier of the calendar. More...
 
void set_Uid (int32_t value)
 Sets the unique identifier of the calendar. More...
 
const System::SharedPtr< WeekDayCollection > & get_WeekDays () const
 Gets WeekDaysCollection for this calendar. The collection of weekdays that defines the calendar. More...
 
System::SharedPtr< CalendarExceptionCollectionget_Exceptions () const
 Gets CalendarExceptionCollection object. The collection of exceptions that is associated with the calendar. More...
 
const System::SharedPtr< WorkWeekCollection > & get_WorkWeeks () const
 Gets WorkWeekCollections object. The collection of work weeks that is associated with the calendar. More...
 
bool get_IsBaseCalendar ()
 Gets a value indicating whether the calendar is a base calendar. More...
 
System::SharedPtr< Calendarget_BaseCalendar () const
 Gets the base calendar on which this calendar depends. Only applicable if the calendar is not a base calendar. More...
 
void set_BaseCalendar (const System::SharedPtr< Calendar > &value)
 Sets the base calendar on which this calendar depends. Only applicable if the calendar is not a base calendar. More...
 
bool get_IsBaselineCalendar ()
 Gets a value indicating whether the calendar is a baseline calendar. More...
 
void set_IsBaselineCalendar (bool value)
 Sets a value indicating whether the calendar is a baseline calendar. More...
 
System::String get_Guid () const
 Gets calendar's Guid. More...
 
bool Equals (System::SharedPtr< System::Object > obj) override
 Returns a value indicating whether this instance is equal to a specified object. More...
 
int32_t GetHashCode () const override
 Returns a hash code for the instance of the class. More...
 
void Delete ()
 Removes calendar from project. More...
 
System::DateTime GetStartDateFromFinishAndDuration (System::DateTime finish, Duration duration) override
 Returns start date based on the specified finish date and duration. More...
 
System::DateTime GetStartDateFromFinishAndDuration (System::DateTime finish, System::TimeSpan duration) override
 Returns start date based on specified finish date and duration. More...
 
bool IsDayWorking (System::DateTime dt) override
 Determines whether the specified day is a working day according to the calendar. More...
 
System::SharedPtr< WorkUnitGetWorkingHours (System::DateTime start, System::DateTime finish) override
 Return WorkUnit - Start, Finish and Duration of working hours for the specified date time interval. More...
 
System::TimeSpan GetWorkingHours (System::DateTime dt) override
 Returns the amount of working hours at the specified date. More...
 
System::TimeSpan GetWorkingHoursTimeSpan (System::DateTime start, System::DateTime finish) override
 Returns amount of working hours between the specified dates. More...
 
System::DateTime GetFinishDateByStartAndWork (System::DateTime start, Duration work) override
 Calculates the date when the specified amount of work time will pass according to the calendar. More...
 
System::DateTime GetFinishDateByStartAndWork (System::DateTime start, System::TimeSpan work) override
 Calculates the date when the specified amount of work time will pass according to the calendar. More...
 
System::DateTime GetTaskFinishDateFromDuration (System::SharedPtr< Task > task, System::TimeSpan duration) override
 Calculates the task finish date and time from its start date, split parts and the work duration. More...
 
System::SharedPtr< WorkingTimeCollectionGetWorkingTimes (System::DateTime dt) override
 Returns WorkingTimeCollection of working times for the specified date. More...
 
System::DateTime GetPreviousWorkingDayEnd (System::DateTime date) override
 Calculates the end of the previous working date from the specified date. More...
 
System::DateTime GetNextWorkingDayStart (System::DateTime date) override
 Calculates next working day start for the specified date. More...
 
System::DateTime GetWorkStart (System::DateTime date) override
 Calculates next working time start beginning from the specified date and time. More...
 
bool IsEmpty () override
 Returns whether the calendar doesn't have working hours defined. More...
 

Static Public Member Functions

static System::SharedPtr< ICalendarGetIntersectionCalendar (const System::SharedPtr< Calendar > &calendar1, const System::SharedPtr< Calendar > &calendar2)
 Gets ICalendar instance which can be used to perform calculations on the intersection of work schedules of 2 calendars. More...
 
static System::SharedPtr< CalendarMakeStandardCalendar (const System::SharedPtr< Calendar > &calendar)
 Creates default standard calendar. More...
 
static System::SharedPtr< CalendarMake24HourCalendar (const System::SharedPtr< Calendar > &calendar)
 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. More...
 
static System::SharedPtr< CalendarMakeNightShiftCalendar (const System::SharedPtr< Calendar > &calendar)
 Makes a given Calendar as Night Shift Calendar. More...
 

Detailed Description

Represents a calendar used in a project.

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))

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.

Member Function Documentation

◆ Delete()

void Aspose::Tasks::Calendar::Delete ( )

Removes calendar from project.

◆ Equals()

bool Aspose::Tasks::Calendar::Equals ( System::SharedPtr< System::Object >  obj)
override

Returns a value indicating whether this instance is equal to a specified object.

Parameters
objThe object to compare with this instance.
Returns
True if o is a Calendar that has the same Uid value as this instance; otherwise, false.

◆ get_BaseCalendar()

System::SharedPtr<Calendar> Aspose::Tasks::Calendar::get_BaseCalendar ( ) const

Gets the base calendar on which this calendar depends. Only applicable if the calendar is not a base calendar.

◆ get_Exceptions()

System::SharedPtr<CalendarExceptionCollection> Aspose::Tasks::Calendar::get_Exceptions ( ) const

Gets CalendarExceptionCollection object. The collection of exceptions that is associated with the calendar.

◆ get_Guid()

System::String Aspose::Tasks::Calendar::get_Guid ( ) const

Gets calendar's Guid.

◆ get_IsBaseCalendar()

bool Aspose::Tasks::Calendar::get_IsBaseCalendar ( )

Gets a value indicating whether the calendar is a base calendar.

◆ get_IsBaselineCalendar()

bool Aspose::Tasks::Calendar::get_IsBaselineCalendar ( )

Gets a value indicating whether the calendar is a baseline calendar.

◆ get_Name()

System::String Aspose::Tasks::Calendar::get_Name ( ) const

Gets the name of the calendar.

◆ get_Uid()

int32_t Aspose::Tasks::Calendar::get_Uid ( ) const

Gets the unique identifier of the calendar.

◆ get_WeekDays()

const System::SharedPtr<WeekDayCollection>& Aspose::Tasks::Calendar::get_WeekDays ( ) const

Gets WeekDaysCollection for this calendar. The collection of weekdays that defines the calendar.

◆ get_WorkWeeks()

const System::SharedPtr<WorkWeekCollection>& Aspose::Tasks::Calendar::get_WorkWeeks ( ) const

Gets WorkWeekCollections object. The collection of work weeks that is associated with the calendar.

◆ GetFinishDateByStartAndWork() [1/2]

System::DateTime Aspose::Tasks::Calendar::GetFinishDateByStartAndWork ( System::DateTime  start,
Duration  work 
)
overridevirtual

Calculates the date when the specified amount of work time will pass according to the calendar.

Parameters
startStart date.
workWork duration.
Returns
Finish date.

Implements Aspose::Tasks::ICalendar.

◆ GetFinishDateByStartAndWork() [2/2]

System::DateTime Aspose::Tasks::Calendar::GetFinishDateByStartAndWork ( System::DateTime  start,
System::TimeSpan  work 
)
overridevirtual

Calculates the date when the specified amount of work time will pass according to the calendar.

Parameters
startStart date.
workWork duration.
Returns
Finish date.

Implements Aspose::Tasks::ICalendar.

◆ GetHashCode()

int32_t Aspose::Tasks::Calendar::GetHashCode ( ) const
override

Returns a hash code for the instance of the class.

Returns
a hash code for this object.

◆ GetIntersectionCalendar()

static System::SharedPtr<ICalendar> Aspose::Tasks::Calendar::GetIntersectionCalendar ( const System::SharedPtr< Calendar > &  calendar1,
const System::SharedPtr< Calendar > &  calendar2 
)
static

Gets ICalendar instance which can be used to perform calculations on the intersection of work schedules of 2 calendars.

Parameters
calendar1First calendar.
calendar2Second calendar.
Returns
Implementation of ICalendar interface.
Exceptions
ArgumentNullExceptionWhen any of the arguments is null.

◆ GetNextWorkingDayStart()

System::DateTime Aspose::Tasks::Calendar::GetNextWorkingDayStart ( System::DateTime  date)
overridevirtual

Calculates next working day start for the specified date.

Parameters
dateThe date to get next working day start for.
Returns
Next working day start System::DateTime.

Implements Aspose::Tasks::ICalendar.

◆ GetPreviousWorkingDayEnd()

System::DateTime Aspose::Tasks::Calendar::GetPreviousWorkingDayEnd ( System::DateTime  date)
overridevirtual

Calculates the end of the previous working date from the specified date.

Parameters
datethe date to calculate the previous working day end.
Returns
The end of the previous working day end

Implements Aspose::Tasks::ICalendar.

◆ GetStartDateFromFinishAndDuration() [1/2]

System::DateTime Aspose::Tasks::Calendar::GetStartDateFromFinishAndDuration ( System::DateTime  finish,
Duration  duration 
)
overridevirtual

Returns start date based on the specified finish date and duration.

Parameters
finishThe specified finish date.
durationThe specified duration.
Returns
Calculated start date.

Implements Aspose::Tasks::ICalendar.

◆ GetStartDateFromFinishAndDuration() [2/2]

System::DateTime Aspose::Tasks::Calendar::GetStartDateFromFinishAndDuration ( System::DateTime  finish,
System::TimeSpan  duration 
)
overridevirtual

Returns start date based on specified finish date and duration.

Parameters
finishThe specified finish date.
durationThe specified duration.
Returns
Calculated start date.

Implements Aspose::Tasks::ICalendar.

◆ GetTaskFinishDateFromDuration()

System::DateTime Aspose::Tasks::Calendar::GetTaskFinishDateFromDuration ( System::SharedPtr< Task task,
System::TimeSpan  duration 
)
overridevirtual

Calculates the task finish date and time from its start date, split parts and the work duration.

Parameters
taskThe task to calculate finish date for.
durationThe duration to calculate.
Returns
Task's finish date for the given start date and duration.

Returns DateTime.MinValue if task is summary, null or its start date is not set.

Implements Aspose::Tasks::ICalendar.

◆ GetWorkingHours() [1/2]

System::TimeSpan Aspose::Tasks::Calendar::GetWorkingHours ( System::DateTime  dt)
overridevirtual

Returns the amount of working hours at the specified date.

Parameters
dtThe date to get working hours for.
Returns
Working hours at the specified date.

Implements Aspose::Tasks::ICalendar.

◆ GetWorkingHours() [2/2]

System::SharedPtr<WorkUnit> Aspose::Tasks::Calendar::GetWorkingHours ( System::DateTime  start,
System::DateTime  finish 
)
overridevirtual

Return WorkUnit - Start, Finish and Duration of working hours for the specified date time interval.

Parameters
startStart date of the interval.
finishFinish date of the interval.
Returns
Instance of WorkUnit class containing Start, Finish and Duration of working hours.

Implements Aspose::Tasks::ICalendar.

◆ GetWorkingHoursTimeSpan()

System::TimeSpan Aspose::Tasks::Calendar::GetWorkingHoursTimeSpan ( System::DateTime  start,
System::DateTime  finish 
)
overridevirtual

Returns amount of working hours between the specified dates.

Parameters
startStart date of the interval.
finishFinish date of the interval.
Returns
Amount of working hours according to the calendar instance.

Implements Aspose::Tasks::ICalendar.

◆ GetWorkingTimes()

System::SharedPtr<WorkingTimeCollection> Aspose::Tasks::Calendar::GetWorkingTimes ( System::DateTime  dt)
overridevirtual

Returns WorkingTimeCollection of working times for the specified date.

Parameters
dtThe date to get working times for.
Returns
Collection of WorkingTime instances.

Implements Aspose::Tasks::ICalendar.

◆ GetWorkStart()

System::DateTime Aspose::Tasks::Calendar::GetWorkStart ( System::DateTime  date)
overridevirtual

Calculates next working time start beginning from the specified date and time.

Parameters
dateThe date and time.
Returns
The nearest working time start.

Implements Aspose::Tasks::ICalendar.

◆ IsDayWorking()

bool Aspose::Tasks::Calendar::IsDayWorking ( System::DateTime  dt)
overridevirtual

Determines whether the specified day is a working day according to the calendar.

Parameters
dtThe date to check whether the day is working.
Returns
True if the day is a working day.

Implements Aspose::Tasks::ICalendar.

◆ IsEmpty()

bool Aspose::Tasks::Calendar::IsEmpty ( )
overridevirtual

Returns whether the calendar doesn't have working hours defined.

Implements Aspose::Tasks::ICalendar.

◆ Make24HourCalendar()

static System::SharedPtr<Calendar> Aspose::Tasks::Calendar::Make24HourCalendar ( const System::SharedPtr< Calendar > &  calendar)
static

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.

Parameters
calendarCalendar to make 24 Hours Calendar from.
Returns
24Hour Calendar.

◆ MakeNightShiftCalendar()

static System::SharedPtr<Calendar> Aspose::Tasks::Calendar::MakeNightShiftCalendar ( const System::SharedPtr< Calendar > &  calendar)
static

Makes a given Calendar as Night Shift Calendar.

Parameters
calendarCalendar to make Night Shift Calendar.
Returns
Night Shift Calendar.

◆ MakeStandardCalendar()

static System::SharedPtr<Calendar> Aspose::Tasks::Calendar::MakeStandardCalendar ( const System::SharedPtr< Calendar > &  calendar)
static

Creates default standard calendar.

Parameters
calendarCalendar to make standard calendar from.
Returns
Calendar with 5 working days (Monday-Friday) with working times 8-12 and 13-17.

◆ set_BaseCalendar()

void Aspose::Tasks::Calendar::set_BaseCalendar ( const System::SharedPtr< Calendar > &  value)

Sets the base calendar on which this calendar depends. Only applicable if the calendar is not a base calendar.

◆ set_IsBaselineCalendar()

void Aspose::Tasks::Calendar::set_IsBaselineCalendar ( bool  value)

Sets a value indicating whether the calendar is a baseline calendar.

◆ set_Name()

void Aspose::Tasks::Calendar::set_Name ( const System::String &  value)

Sets the name of the calendar.

◆ set_Uid()

void Aspose::Tasks::Calendar::set_Uid ( int32_t  value)

Sets the unique identifier of the calendar.