Hi,
I am having an issue with the updateTask method throwing an invalid date format when I attempt to call this method with an existing task.
The code snippet is below:
if (!gantt.isTaskExists(task.id)) {
task.duration = self.getTaskDuration(task);
task.id = self.addNewTask(task);
} else {
gantt.updateTask(task.id, task);
}
The task object being passed to updateTask is:
{ color: "#f2552c"
duration: 90
end_date: "2021-04-01 00:00:00"
id: 137
open: true
parent: ""
start_date: "2021-01-01 00:00:00"
text: "Task A"
}
The gantt.config.date_format value is set to:
gantt.config.date_format = "%Y-%m-%d %H:%M:%S";
The error thrown is:
dhtmlxgantt.js:11 Uncaught Error: Invalid start_date argument for getDuration method
at Object._getStartEndConfig (dhtmlxgantt.js:11)
at Object.getDurationArguments (dhtmlxgantt.js:11)
at a.calculateDuration (dhtmlxgantt.js:11)
at Object.calculateDuration (dhtmlxgantt.js:11)
at Object.t._init_task_timing (dhtmlxgantt.js:11)
at Object.<anonymous> (dhtmlxgantt.js:11)
at Object.i (dhtmlxgantt.js:11)
at Object.t.callEvent (dhtmlxgantt.js:11)
at s.<anonymous> (dhtmlxgantt.js:11)
at s.i (dhtmlxgantt.js:11)
at s.t.callEvent (dhtmlxgantt.js:11)
at s.updateItem (dhtmlxgantt.js:11)
at Object.updateTask (dhtmlxgantt.js:11)
I have also tried all of the following formats but they all fail as invalid date format:
- an instance of Date()
- converted to ISO string using toISOString()
- converted to UTC string using toUTCString()
- converted to string using toString()
I would appreciate any guidance that would help me resolve this error.