Calendar.GetWorkingHours

GetWorkingHours(DateTime, DateTime)

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

public WorkUnit GetWorkingHours(DateTime start, DateTime finish)
ParameterTypeDescription
startDateTimeStart date of the interval.
finishDateTimeFinish date of the interval.

Return Value

Instance of WorkUnit class containing Start, Finish and Duration of working hours.

Examples

Shows how to get working hours for specific dates.

var project = new Project(DataDir + "Project1.mpp");

var calendar = project.Calendars.GetByUid(1);

// get working hours for specific date
var workUnit = calendar.GetWorkingHours(new DateTime(2020, 4, 8, 8, 0, 0), new DateTime(2020, 4, 9, 17, 0, 0));

// 16 hours will be printed
Console.WriteLine(workUnit.WorkingHours);

See Also


GetWorkingHours(DateTime)

Returns the amount of working hours at the specified date.

public TimeSpan GetWorkingHours(DateTime dt)
ParameterTypeDescription
dtDateTimeThe date to get working hours for.

Return Value

Working hours at the specified date.

Examples

Shows how to get working hours for a specific date.

var project = new Project(DataDir + "Project1.mpp");

var calendar = project.Calendars.GetByUid(1);

// get working hours for specific date
var workingHours = calendar.GetWorkingHours(new DateTime(2020, 4, 10));

// 8 hours will be printed
Console.WriteLine(workingHours.Hours);

See Also