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

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

#include <Calendar.h>

Inherits System::Object.

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)
 Returns StartDate based on specified FinishDate and Duration. More...
 
System::DateTime GetStartDateFromFinishAndDuration (System::DateTime finish, System::TimeSpan duration)
 Returns StartDate based on specified FinishDate and Duration. More...
 
bool IsDayWorking (System::DateTime dt)
 Determines whether the day is working day. More...
 
System::SharedPtr< WorkUnitGetWorkingHours (System::DateTime start, System::DateTime finish)
 Return working hours for the specified dates. More...
 
System::DateTime GetFinishDateByStartAndWork (System::DateTime start, Duration work)
 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)
 Calculates the date when the specified amount of work time will pass according to the calendar. More...
 
System::DateTime GetTaskFinishDateFromDuration (const System::SharedPtr< Task > &task, System::TimeSpan duration)
 Calculates the task finish date and time from its start date, split parts and the duration. More...
 
System::TimeSpan GetWorkingHours (System::DateTime dt)
 Returns amount of working hours at the date. More...
 
System::SharedPtr< WorkingTimeCollectionGetWorkingTimes (System::DateTime dt)
 Returns WorkingTimeCollection of working times for the specified date. More...
 
System::DateTime GetPreviousWorkingDayEnd (System::DateTime date)
 Calculates previous working date end from the specified date. More...
 
System::DateTime GetNextWorkingDayStart (System::DateTime date)
 Calculates next working day start from the date. More...
 

Static Public Member Functions

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 
)

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

Parameters
startStart date.
workWork duration.
Returns
Finish date.

◆ GetFinishDateByStartAndWork() [2/2]

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

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

Parameters
startStart date.
workWork duration.
Returns
Finish date.

◆ 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.

◆ GetNextWorkingDayStart()

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

Calculates next working day start from the date.

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

◆ GetPreviousWorkingDayEnd()

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

Calculates previous working date end from the specified date.

Parameters
datethe specified instance of DateTime struct.
Returns
Previous working day start System::DateTime

◆ GetStartDateFromFinishAndDuration() [1/2]

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

Returns StartDate based on specified FinishDate and Duration.

Parameters
finishThe specified finish date.
durationThe specified work duration.
Returns
Calculated StartDate.

◆ GetStartDateFromFinishAndDuration() [2/2]

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

Returns StartDate based on specified FinishDate and Duration.

Parameters
finishThe specified finish date.
durationThe specified work duration.
Returns
Calculated StartDate.

◆ GetTaskFinishDateFromDuration()

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

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

Parameters
taskThe task to get finish date for.
durationThe task duration to split on.
Returns
Task's finish date.

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

◆ GetWorkingHours() [1/2]

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

Returns amount of working hours at the date.

Parameters
dtThe date to get working hours for.
Returns
Working hours.

◆ GetWorkingHours() [2/2]

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

Return working hours for the specified dates.

Parameters
startStart date.
finishFinish date.
Returns
Working hours.

◆ GetWorkingTimes()

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

Returns WorkingTimeCollection of working times for the specified date.

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

◆ IsDayWorking()

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

Determines whether the day is working day.

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

◆ 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.