On the problem of unit precision of construction period calculation

I have a problem with the accuracy of the time calculation. For example, if I input a 1.5 hour period and calculate the end date, my start date is 2023-2-18,8:00, the duration is in hours, but the end date is finally calculated to me as 2023-2-19,0:0. In addition, 2023-2-18 is a special date, the working hours are [9:30-12:00]; May I ask if the decimal number will be automatically rounded off when the duration unit is hours, and the schedule will be discarded?

The calendar is configured as shown above;

Gantt stores the duration in the integer format. There is no way to change that. If you set a decimal duration, only the integer part will remain. The duration will be rounded depending on the duration_unit parameter:
If it is “day” (default), it will be 0. For “hour”, it will be 2 hours.
Here is an example (check task #4):

But you can change what is displayed to the user. There is a Formatter extension that converts the duration, but internally, it will be stored in the integer format in the smaller unit:
You need to store the duration in minutes if you want to see a decimal duration in hours.
Here is an example:

Thank you for your reply. However, I am sorry that I may not have expressed it clearly before. The specific question is as follows:
According to the normal calculation result, the result should be 2023-2-189:30, but the final result is unexpected. The final calculation result is Sat Feb 11 2023 00:00:00 GMT+0800 (Chinese standard time).
The general method is as follows:
Looking forward to your reply!

If you specify a decimal value in the calculateEndDate method, it will not work as you expect. As I said before, Gantt cannot work with decimal values internally. The decimal part will be removed. Moreover, the string format should not be used in that method as it expects the Date object as the first parameter or the start_date parameter:

You will get an error if you try to pass a string:

You need to convert the decimal value with the duration formatter:

Then you can use the returned value in the calculateEndDate method. But you need to use the “minute” unit to convert the duration value and not round it to hours. Otherwise, you will get 2 hours.

Here is an example:

Thank you for your help!

Sorry to bother you again, I got another question here, which is the “getClosestWorkTime” method, which I find a little weird.
For example:
The method invocation is shown in the figure above, but the result is somewhat unexpected:
Could you please explain the logic of this method? Thank you!
Looking forward to your reply

The getClosestWorkTime method obtains the working time that is closest to the provided date.

The difference between 17:00 and 24:00 is 7, while the difference between 24:00 and 08:00 is 8. So, it is expected that Gantt chooses 17:00.

You may think that the closest working time to the left side would be 16:00, but there is 1 working hour between 16:00 and 17:00. As at 17:00 the working time starts (if you calculate the dates from right to left), Gantt chooses this hour.

If you want to obtain the closest working time in the future, you need to specify the direction in the dir parameter.

Here is an example in the snippet: