跳到主要内容

calculateDuration

Description

计算任务的持续时间

calculateDuration: (config: object, end_date: Date) => number

Parameters

  • config - (required) object | Date - 要么是时间段的 配置对象,要么是任务的开始日期
  • end_date - (optional) Date - 任务的结束日期。当第一个参数指定为 start_date 时,该参数为必填。

Returns

  • duration - (number) - 任务的持续时间,单位由 duration_unit 选项指定

Example

gantt.config.work_time = true;
gantt.init("gantt_here");

// 获取两个日期之间的工作时间时长
// (适用于有多个工作日历的任务)
gantt.calculateDuration({
start_date: new Date(2013,02,15),
end_date: new Date(2013,02,25)
/*,task: task*/
});

// or
gantt.calculateDuration(task);

// or
gantt.calculateDuration(new Date(2013,02,15), new Date(2013,02,25)); //->6

Details

注释

如果启用 work_time 选项,该方法将以工作时间计算任务的持续时间。

配置对象属性

配置对象可以包含以下属性:

  • start_date - (Date) 任务计划开始的日期
  • end_date - (Date) 任务计划完成的日期
  • task - (object) 可选,需要计算持续时间的任务对象
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.