@sentientsoft ,
new DateTime(2023, 12, 22) results in “2023-12-22 00:00:00” date. It’s a non-working time. The nearest working time is 2023-12-21, 5:00:00 PM.
It would be more user-friendly to add logic similar to MS Project: when the user sets a date without specifying a time, the system automatically adds the default end time from the project’s settings.
The API given DateTime with Time == 00:00:00 cannot distinguish whether the user created it without specifying a time or intentionally set it to midnight. In other words, in .NET we cannot distinguish between d1 and d2:
var d1 = DateTime(2023, 12, 22);
var d2 = DateTime(2023, 12, 22, 0, 0, 0);
Thus adding the described logic would be frustrating for users who intentionally want to set the finish time to new DateTime(2023, 12, 22, 0, 0, 0).
I recommend explicitly specifying times according to the relevant calendar (project’s, task’s, or resource’s calendar).
For example, the default calendar for a project created with the default ctor (var project = new Project()) is a 5-day schedule with working hours 08:00 - 12:00, 13:00-17:00.
In your code, you could set dates and times like this:
task.Start = new DateTime(2023, 12, 1, 8, 0, 0);
task.Finish = new DateTime(2023, 12, 22, 17, 0, 0).
There is another concern: once the issue TASKSNET-11594 is fixed, setting
task.Set(Tsk.Finish, new DateTime(2023, 12, 22))
will be interpreted as explicitly setting finish to a non-working time 2023-12-22 00:00:00.
As a result the interval [2023-12-21 17:00:00 - 2023-12-22 0:00:00] will be marked as implicit working time (as MS Project does when you set finish to 2023-12-22 0:00:00) which can lead an unexpected results.