Hi We want difference between two days based on calendar for task . In hours unit
Support Forum
Hi rahulranjan,
const duration = gantt.project.calendar.calculateDurationMs(startDate, endDate);
const durationInHours = gantt.project.convertDuration(duration, "millisecond", "hour");
https://bryntum.com/docs/gantt/engine/classes/_lib_engine_quark_model_abstractcalendarmixin_.abstractcalendarmixin.html#calculatedurationms
https://bryntum.com/docs/gantt/engine/classes/_lib_engine_quark_model_gantt_ganttprojectmixin_.ganttprojectmixin.html#convertduration
All the best,
Alex
HI
For Each task there can be different calendars assigned to it
Let Say
Task 1 Cal 1
Task 2 Cal 2
Now when i selected task1 and i want difference between two dates based on Cal1 ?
Same carries for Task2 and Dates Difference will be based on Cal2
Because Each Calendar will have different working time duration
Could you please describe your use case in more details?
Every calendar has this method. Just get the calendar that you need and calculate a duration.
gantt.project.calendar
is a tree record, check its children
.
If you want to get a calendar assigned to a task, use:
https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#field-calendar
All the best,
Alex
alex.l wrote: ↑Tue Feb 16, 2021 12:32 pmCould you please describe your use case in more details?
Every calendar has this method. Just get the calendar that you need and calculate a duration.
gantt.project.calendar
is a tree record, check itschildren
.
If you want to get a calendar assigned to a task, use:
https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#field-calendar
How to get the calendar of task and Pass it to gantt.project.calendar this ? for Date Difference calculation based on calendar
The above function calculateDurationMs
takes 2 arguments that can be any dates (Date_1, Date_2). This is the method of calendar so you if you want to base the results on Cal_2 then you would call (pseudocode):
const cal2 = task2.calendar;
const duration = cal2.calculateDurationMs(task1.date1, task1.date2);