Page 1 of 1

[REACT] Calculation of end date with other calendar

Posted: Sun May 28, 2023 9:42 pm
by burnit

Hi,

today i can calculate the endDate by using the generator function 'calculateProjectedXDateWithDuration' when i pass in the startDate and duration of the event.

But how can i calculate the end date, based on another calendar?
(for example: event is assigned to calendar 'twoShifts' but i want to calculate the end date based on calendar 'threeShifts'

Many thanks.


Re: [REACT] Calculation of end date with other calendar

Posted: Mon May 29, 2023 5:13 pm
by alex.l

Hi, try to call in calendar you need calculateEndDate method.

const endDate = gantt.project.calendarManagerStore.getById('general').calculateEndDate(startDate, duration);

Re: [REACT] Calculation of end date with other calendar

Posted: Mon May 29, 2023 5:37 pm
by burnit

Thanks for this great idea!

But i am facing this issue:

Screenshot 2023-05-29 173531.png
Screenshot 2023-05-29 173531.png (7.45 KiB) Viewed 318 times

So my input is my startDate as date and my duration as number.
But the output is exactly the same as my start Date or the beginning of the working interval.
Any idea what the reason could be?

                  console.log(form.startDate, form.duration);
                  const endDate = calendarStore
                    .getById(values.target.value)
                    .calculateEndDate(form.startDate, form.duration);
                  console.log(endDate);

Re: [REACT] Calculation of end date with other calendar

Posted: Mon May 29, 2023 6:52 pm
by alex.l

Yes, I actually forgot to mention that duration must be in milliseconds. Sorry about that.


Re: [REACT] Calculation of end date with other calendar

Posted: Tue May 30, 2023 12:21 am
by burnit

Works! Thanks a lot!