Task duration issue with different calendar than standard

Hi all,

I am working with different calendar other than the standard. Which is basically 16hr calendar
5 day working monday to friday and working times are
Shift1 - 6 am to 2pm,
Shift 2- 3pm to 11pm

When I am mapping my concerto task(4 days) which has start date as 29 august,2022 and end date 01 sept,2022 to ms project record.

I am creating duration object as
tsk is concerto task object
Task atsk = project.RootTask.Children.Add(tsk.Name);

atsk.Set(Tsk.Start, tsk.Start);
atsk.Set(Tsk.Finish, tsk.Finish);
Duration remdur = project.GetDuration(days, TimeUnitType.Day);

atsk.Set(Tsk.RemainingDuration,remdur);

Problem I am facing is that duration object always contains total minues /total seconds based on default calendar(standard 8hr calendar) .

I have already set project with 16hr working hour calendar

Please suggest how to resolve this

@cshekhar,
I’ve tried to to project’s calendar to the described calendar and tasks calculation seems correct.

Can you please share sample code which can be compiled so that we may further investigate to help you out.

I am expecting task start date as 29/08/2022 and finish date as 01/09/2022 But its displaying
start date as 29/08/2022 and finish date as 30/08/202.

I have attached the source code. please check

MPPRequestedFiles.zip (9.5 MB)

@cshekhar,

thank you for the example.

In fact, duration should be 8d (64 hours) for task with calendar you’ve described and start date = 29/08/2022 and finish date = 01/09/2022, but you’ve explicitly set it to 4d (32 hours) and so finish date was recalculated to 30/09/2022.

Why task duration is 8d, not 4d ?

You can check it in MS Project (here I set the 2-shift project’s calendar):
Screenshot_1.png (11.7 KB)

MS Project calculates task’s duration in hours (64), divides it by number of hours set by ‘Hours per day’ project’s setting (default is 8) and display ‘8 days’ duration, it doesn’t take into account the fact that your project’s calendar have 16-hours working day.

The same behavior is implemented in Aspose.Tasks.