Calendar Exceptions not honored with GetFinishDateByStartAndWork with new Project

I am using the latest version Aspose.Tasks 8.5 and trying to calculate the finish date of a task given a start date and duration of 48 hours (so it should be 6 days later for 8 hour days). I have a single calendar exception on a single Saturday that I would like to be a working day. I am expecting the code below to return 7/21/2015 5:00pm, but I am getting 7/22/2015 5:00pm.


I tried loading a saved project file to see what the differences were in the properties and it was setting my exception years to 2000. I mention this because this also reappears when I save the project to XML and load it into MS Project, my exception on Calendar1 is in the year 2000, although i specified 2015.

Start Date: 7/15/2015 8:00am
Duration: 48 hours (6 work days)
Normal Work Days: Monday through Friday
Exceptions: 7/18 needs to be a work day
Expectation: Finish Date is 7/21/2015 5:00pm

Objective: Have duration include a single Saturday, but not make Saturday a normal working day.

What might I be doing wrong?
DateTime startDate = DateTime.Parse(“7/15/2015 8:00am”);
DateTime finishDate;
TimeSpan duration = new TimeSpan(8 * 6, 0, 0);

Project project = new Project();
Calendar calendar = project.Calendars.Add(“Calendar1”);

calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Monday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Tuesday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Wednesday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Thursday));
calendar.WeekDays.Add(WeekDay.CreateDefaultWorkingDay(DayType.Friday));
calendar.WeekDays.Add(new WeekDay(DayType.Saturday));
calendar.WeekDays.Add(new WeekDay(DayType.Sunday));

WorkingTime wt1 = new WorkingTime();
wt1.FromTime = new DateTime(1, 1, 1, 8, 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, 13, 0, 0, 0);
wt2.ToTime = new DateTime(1, 1, 1, 17, 0, 0, 0);

CalendarException calExc = new CalendarException();
calExc.FromDate = new System.DateTime(2015, 7, 18);
calExc.ToDate = new System.DateTime(2015, 7, 18);
calExc.WorkingTimes.Add(wt1);
calExc.WorkingTimes.Add(wt2);
calExc.DayWorking = true;
calExc.EnteredByOccurrences = true;
calExc.Name = “Test”;
calExc.Occurrences = 1;
calExc.Period = 1;
calExc.Type = CalendarExceptionType.Daily;
calendar.Exceptions.Add(calExc);

finishDate = calendar.GetFinishDateByStartAndWork(startDate, duration);
Console.WriteLine(finishDate);


Hi Christopher,


Thank you for contacting Aspose support team.

I have tested you code without any change and got Finish Date 7/21/2015 5:00 pm as shown in the attached snapshot. I have also tested the calendar exception in the saved XML file and observed that if we don’t use valid license, the exception date is set to year 2000. However if a valid license is used, then this date is set to year 2015.

If you want to test Aspose.Tasks without evaluation version limitations, you can request a 30 Day Temporary License. Please refer here to get the temporary license, test the scenario again and share the feedback with us.


Thank you for your quick response. You were correct with the license being the cause in my scenario. When I upgraded to test against the latest version, not only was my license no longer valid but I had added the Working Times at the same time I upgraded. So there was a few things working against me but from your response I was able to work out where I went wrong. My original code (that i did not supply here) just needed the working times set on the exception and now it is working as expected.


Thanks

Hi Christopher,


We are glad to know that your issue is resolved and hank you for providing feedback. Please feel free to write us back for any other query related to Aspose.Tasks.