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

Custom method for Business hours calculation

Asked by Wolfgang
2 years 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 years ago.

Hi Wolfgang,

It's possible to adjust the start/end using onEventMoving while the event is being dragged:

There is also a related tutorial:

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) {
  var start = args.newStart.addHours(2);
  var end = args.newEnd.addHours(2);

See also:

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

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.