getClosestWorkTime

returns the closest working time

Date getClosestWorkTime(object config);

Parameters

configobjectthe configuration object

Returns

Datea Date object of the closest working time

Example

// checks whether the specified date is a working day in global settings
gantt.getClosestWorkTime({date:new Date(2019,04,26)});
// or
gantt.getClosestWorkTime(new Date(2019,04,26));
 
// checks whether the specified date is a working day for a specific task
gantt.getClosestWorkTime({ date: new Date(2019,04,26), task:task });

Details

If the work_time option is disabled, the method returns the date unchanged.

Configuration object properties

The configuration object can contain the following properties:

Property Description
date a date to get the closest working time for
gantt.getClosestWorkTime({
    date:new Date(2019,04,26),
    dir:"future"
});
// -> Mon May 27 2019 00:00:00 if duration_unit="day"
// -> Mon May 27 2019 08:00:00 if duration_unit="hour"
dir ('future' or 'past') specifies the direction of the closest time
gantt.getClosestWorkTime({
    date:new Date(2019,04,18),
    dir:"past"
});
// -> Sat May 18 2019 00:00:00
unit a time unit to search for the closest working time
//searches for the closest working hour
gantt.getClosestWorkTime({
    date:new Date(2019,04,18), 
    dir:"future", 
    unit:"hour"
});
// -> Mon May 20 2019 08:00:00
task optional, the object of the task the duration of which should be calculated
var closestTime = gantt.getClosestWorkTime({
    date:date, 
    task:task
});
See also
Back to top