Read Calendar Information from Project Files
Retrieving Calendar Information
Microsoft Project lets users associate a variety of different calendars with working time, tasks and resources. These features are also available in Aspose.Tasks. This topic explains how to retrieve information about which calendars are used in a project. Aspose.Tasks can retrieve calendar information for all versions of Microsoft Project: 2003, 2007, 2010, and 2013.
To view calendar information in Microsoft Project:
- Open a project.
- From the Project menu, select Change Working Time.
The following piece of code retrieves the calendar information from a project.
Reading Work Weeks Information from Calendar
Aspose.Tasks for .NET API can read Work weeks information from any of the Project’s calendar. The WorkWeek class can be used to achieve this.
Getting Working Hours On or Between Dates
Working hours are typically defined as a range of hours over a day, on specific days of the week. For example, 09:00 – 17:00, Monday to Friday. With Aspose.Tasks for .NET, it is possible to calculate the number of working hours that fall on a date, or between two dates. Finding out the number of working dates between two dates help project managers figure out whether there are enough hours to get work done, or if they need to find more resources to complete a task. It is recommended that for calculating the working hours between two dates, complete date and time (hours, minutes and seconds) should be provided for exact calculation. If the only date is given as finish date value say 2016, 8, 18, it will be considered as 0:0:0 hours on that day and, hence, finish date day will not be included in the calculation. However, if the finish date is given as 2016,8,18,17,0,0, then the proper result will be calculated.
The Calendar class exposes two methods(overloaded) for finding working hours on or between dates. GetWorkingHours(DateTime dt) and GetWorkingHours(DateTime startdt, DateTime enddt) to define the working hours between two dates.
The following example shows how to find the duration in minutes, hours and days between two dates.