Duration not calculating correctly


#1

Hi Support,

I crated a sample project to check worktime calculation. In here when I entered same date for start and end date its giving duration as 0.

my configuration as follows.

var startDateEditor = { type: date, map_to: start_date };
var endDateEditor = { type: date, map_to: end_date};
var durationEditor = { type: number, map_to: duration ,formatter: formatter };

{ name: start_date, label: Start time, align: center, editor: startDateEditor },
{ name: end_date, label: End time, align: center, editor: endDateEditor },
{ name: duration, label: Duration, align: center, editor: durationEditor },

gantt.config.auto_scheduling = true;
gantt.config.schedule_from_end = false; //if auto sheduling true , ASAP default contraint for new task

gantt.config.work_time = true; // removes non-working time from calculations
gantt.config.skip_off_time = false; // hides non-working time in the chart
gantt.config.duration_unit = day;//day
gantt.config.round_dnd_dates = false; //to enable drag and drop

// //changes the working time of working days
var workingTime:string=9:00-18:00;
gantt.setWorkTime({ hours:[workingTime] });

//makes a specific date a working day
gantt.setWorkTime({date : new Date(2021, 4, 11)});

//makes a specific date a day-off
gantt.setWorkTime({date:new Date(2021,4,14), hours:false})

var WorkingHoursPerDay :number=8;
var WorkingHoursPerWeek :number=40;
var WorkingDaysPerMonth :number=30;

// formatting the duration
var formatter = gantt.ext.formatters.durationFormatter({
enter: day,
store: day, // duration_unit
format: day,
hoursPerDay: WorkingHoursPerDay,
hoursPerWeek: WorkingHoursPerWeek,
daysPerMonth: WorkingDaysPerMonth
});

can you please let me know where is the issue.


#2

Hello,
If you enter the same date, you will need to specify different hours as by default, the date starts at 00:00.
If you want to specify the date with the inline editor, you will need to create a custom inline editor.

Gantt uses the non-inclusive duration. There is no way to change how Gantt works, but you can change what is displayed to the users by using the templates:
https://docs.dhtmlx.com/gantt/desktop__loading.html#loadingtaskdates
https://docs.dhtmlx.com/gantt/api__gantt_task_end_date_template.html
Here is an example of how it works:
http://snippet.dhtmlx.com/5/6408aee00