Hi,
how can i calculate the end Date, based on duration and startDate?
I found this in the Gantt Product aread, but i doesn't works on the scheduler.
calendar.calculateEndDate(eventRecord.getStartDate(), 13, "idOfTheEvent");
Many thanks!
Do you need working time calendars? Then you'd need Scheduler Pro. If not you can simply use: https://bryntum.com/products/scheduler/docs/api/Core/helper/DateHelper#function-add-static
Hey burnit,
You can use DateHelper for that purpose, you can write something like this:
DateHelper.add(currentStartDate, currentDuration, 'days');
https://bryntum.com/products/schedulerpro/docs/api/Core/helper/DateHelper#function-add-static
Best regards,
Márcio
The EventModel
has calculateProjectedXDateWithDuration
(https://www.bryntum.com/products/schedulerpro/docs/engine/classes/_lib_engine_quark_model_scheduler_pro_schedulerproevent_.schedulerproevent.html#calculateprojectedxdatewithduration) method that can calculate start or end date:
const endDate = yield* task.calculateProjectedXDateWithDuration(startDate, true, duration)
Thanks Mats.
That's my code now:
function* calculateEndDate(task, startDate, isForward, duration) {
const endDate = yield* task.calculateProjectedXDateWithDuration(startDate, isForward, duration);
return endDate
}
const endDate = calculateEndDate(eventRecord, eventRecord.startDate, true, 12);
console.log(endDate)
console.log(endDate.next())
The console logs show me: [[GeneratorState]]: "suspended"
Any ideas?
When i try to use this, i get following error message from the compiler : "Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode."
const endDate = yield* eventRecord.calculateProjectedXDateWithDuration(eventRecord.startDate, true, eventRecord.duration);
If i put it in a function
function* calculateEndDate2(event) {
yield* event.calculateProjectedXDateWithDuration(event.startDate, true, 4);
}
const endDate = calculateEndDate2(eventRecord);
console.log(endDate.next());
My result is:
{
done: false
value: k {
DATA: undefined
context: e {originalData: {…}, meta: {…}, _internalId: 42, stores: Array(1), segmentModelClass: ƒ, …} name: "e-e6caae03-28f7-4b84-b4fa-e71570ba1d5e.$.durationUnit"
self: e {originalData: {…}, meta: {…}, _internalId: 42, stores: Array(1), segmentModelClass: ƒ, …}
}}