Hello everyone,
I’m using dhtmlxGantt configured with unit: "hour" and step: 12 , so task durations are effectively calculated in half-day units .
I’ve noticed that calculateDuration sometimes returns incorrect values, which then affects task behavior (especially during drag & drop).
Examples
With the following configuration (unit: "hour" , step: 12 ):
-
start_date: 01/01/2026 08:00:00
end_date: 02/01/2026 08:00:00
returned duration: 3
(expected: 2) -
start_date: 01/01/2026 08:00:00
end_date: 01/01/2026 20:00:00
returned duration: 1
(correct) -
start_date: 01/01/2026 08:00:00
end_date: 04/01/2026 08:00:00
returned duration: 7
(expected: 6)
Impact
This incorrect duration calculation affects internal gantt logic.
For example, during task drag operations, onTaskDrag appears to rely on calculateDuration . When the returned value is incorrect, the task duration unexpectedly changes after dragging.
Workaround
As a workaround, when I manually calculate durations, I normalize the dates by rounding the time to either 00:00:00 or 12:00:00 before calling calculateDuration .
This produces coherent results in my custom logic.
However, this doesn’t solve cases where calculateDuration is used internally by dhtmlxGantt, and the incorrect values still affect built-in behavior.
Question
Is this a known limitation or expected behavior when using unit: "hour" with step: 12 ?
Is there a recommended way to avoid or override this internal duration calculation to ensure consistent half-day results?
Thanks in advance for your help.