Question about DefaultHoursInDay


#1

Question about DefaultHoursInDay



Hi,

I have a question about how to set the flag DefaultHoursInDay, so that
the property task.duration can be correctly calculated by Aspose.Task.

I set 24 hours for day, 7 working days for week in the calendar
setting, and also set values to task.start, task.duration, task.type
with Aspose.Task, saved the project as xml file, and opened it with MS
Project. But the by MS Project calculated date task.finish is always
incorrect. After checking the saved xml file, I find out that
task.duration is always calculated by Aspose.Task using 8 hours per
day, though 24h should be used.



The following is a sample code to make the question more clear:



Calendar defaultCalendar = file.AddDefaultBaseCalendar();

CalendarHours ch = defaultCalendar.GetCalendarHours(DayOfWeek.Monday);

ch.FromTime1 = System.DateTime.Parse(“00:00:00”);

ch.ToTime1 =
System.DateTime.Parse(“00:00:00”);


… do the same setting for DayOfWeek.Tuesday…DayOfWeek.Sunday



DefaultSettings ds = file.DefaultSettings;

ds.DefaultDurationUnits = TimeUnit.Days;

ds.DefaultDurationIsFixed = true;

–> ds.DefaultHoursInDay = 24;





–> task.Start = new DateTime(2006, 1, 1, 0, 0, 0);

–> task.Duration = new Duration(10, TimeUnit.Days);

task.Type = TaskFixedType.FixedWork;



Since the task.duration for the task is 10 days, and a day is 24 hours,
the duration should be saved in the xml file as PT240H0M0S.

But when checking the saved xml file, I found that the duration is PT80H0M0S (8h*10day=80h):



2006-01-01T08:00:00

PT80H0M0S







Have I missed some additional settings? Checking the settings in MS
Project dialogs, 24h has been correctly set, and 00:00 to 00:00 is also
set in the calendar.



Another question ist, how can I set the standard start time? As in the
upper code, I set the date of task.start to 00:00 as the time, but then
the task.start has 08:00 as time in the xml file
PT80H0M0S



I appreciate any help.