Import MPP file error

https://docs.dhtmlx.com/gantt/samples/08_api/18_load_from_mpp.html

Dates parsed by DHTMLX gantt don’t seem to be correct compared to the original MPP file which has been exported from Microsoft Project. Is MPP the preferred file type or is XML better? Can you please check and advise? Thanks

C14189 - 6.1 - Cl 31 Rev 4b.mpp (388 KB)

Hello Richard,
When you import MSP files, the tasks in the JSON data have only the start_date and duration properties. So, Gantt needs to calculate the end_date parameter.

In DHTMLX Gantt, the task duration and end date depend on the Gantt configuration. For example, when the work_time config is enabled, Gantt skips the weekends when calculating the duration. But by default, they are not skipped:
https://docs.dhtmlx.com/gantt/desktop__working_time.html

Also, it seems that you use the “hour” duration unit in your file, though it doesn’t reflect that. So, you will need to set the duration_unit config to hour:
https://docs.dhtmlx.com/gantt/api__gantt_duration_unit_config.html

As that will make the tasks end earlier (for example, they will have the duration of 3 hours instead of 3 days), you will need to set the end_date parameter as it has a higher priority over the duration parameter. You can obtain it from the Finish parameter in the $raw object of the imported data:

project.data.data.forEach(function(task){
  task.end_date = task.$raw.Finish
})

After that, you will see the duration in hours. To see it in days, you need to use the formatter:
https://docs.dhtmlx.com/gantt/desktop__formatters_ext.html#durationformatter

Here is the snippet with all that configuration:
https://snippet.dhtmlx.com/he67w8t3