getClosestWorkTime
Description
返回最近的工作时间
getClosestWorkTime: (config: object) => Date
Parameters
config- (required) object - 配置对象或日期
Returns
date- (Date) - 最近工作时间的 Date 对象
Example
// 根据全局设置验证给定日期是否为工作日
gantt.getClosestWorkTime({date:new Date(2019,04,26)});
// 或者
gantt.getClosestWorkTime(new Date(2019,04,26));
// 验证给定日期是否为特定任务的工作日
gantt.getClosestWorkTime({ date: new Date(2019,04,26), task:task });
Details
注释
如果 work_time 选项被禁用,方法将返回日期不变。
- 若未指定任务,该方法将使用 global work time calendar。
- 此外,该方法也可以直接从一个 calendar object 调用。
Configuration object properties
配置对象可以包含以下属性:
属性 | 描述 |
|---|---|
| date | 用于获取最近工作时间的日期 |
| |
| dir | ('future' or 'past') 指定最近时间的方向 |
| |
| unit | 用于搜索最近工作时间的时间单位 |
| |
| task | 可选的,需计算持续时间的任务对象 |
| |
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') 指定最近时间的方向
gantt.getClosestWorkTime({
date:new Date(2019,04,18),
dir:"past"
});
// -> Sat May 18 2019 00:00:00
unit 用于搜索最近工作时间的时间单位
//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 可选的,需计算持续时间的任务对象
var closestTime = gantt.getClosestWorkTime({
date:date,
task:task
});
Related API
Related Guides
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.