search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Custom method for Business hours calculation

Asked by Wolfgang
2 months ago.

Hi Dan,

I´ve been using your fantastic DayPilot Scheduler to create a production planning tool, and almost all of the customers feature requests are implemented already.
The only thing I´m struggling with is to implement a decent shift times module. The existing business hours functionality works fine as long as the time model is simple, but for more complex situations it would be ideal to have an own implementation of business hours calculation.

Is it possible to have a custom method to return the start and end date of an event, which (if defined) replaces your method of calculating the 2 timestamps, e.g. while moving the event in time? The 2 timestamps can of course be calculated while initially loading the events from the data source, but on drag and drop the scheduler recalculates the end time of the event, and I´d like to override this calculation by uing my own implementation.

Or maybe, I´m just overseeing an existing possibility to perform this, so I´m really thankful for any recommendation.

Thanks in advance, and keep up the fantastic work :)

Answer posted by Dan Letecky [DayPilot]
2 months ago.

Hi Wolfgang,

It's possible to adjust the start/end using onEventMoving while the event is being dragged:
https://api.daypilot.org/daypilot-scheduler-oneventmoving/

There is also a related tutorial:
https://code.daypilot.org/57279/javascript-scheduler-skip-non-business-cells-during-drag-an

If you don't want to change the moving shadow dimensions using onEventMoving, it is possible to update the event with adjusted start and end in onEventMove. You just need to cancel the default action:

dp.onEventMove = function(args) {
  args.preventDefault();
  var start = args.newStart.addHours(2);
  var end = args.newEnd.addHours(2);
  args.e.start(start);
  args.e.end(end);
  dp.events.update(args.e);
};

See also:
https://api.daypilot.org/daypilot-scheduler-oneventmove/

Let me know if this is not what you are looking for.

New Reply
This reply is
Your name (optional):