Перейти к основному содержимому

isWorkTime

Description

Проверяет, является ли указанная дата рабочей

isWorkTime: Calendar['isWorkTime']

Parameters

  • config - (required) object | Date - либо конфигурационный объект временного диапазона, либо конкретная дата

Returns

  • isWorkTime - (boolean) - true, если указанная дата относится к рабочему времени. В противном случае false

Example

//проверяет, является ли указанная дата рабочим днем в глобальных настройках
gantt.isWorkTime({ date: new Date(2023,3,5) });
// или
gantt.isWorkTime(new Date(2023,3,5));

//проверяет, является ли указанная дата рабочим днем для конкретной задачи
gantt.isWorkTime({date: new Date(2023,3,5), task: task});

Details

заметка

If the work_time option is disabled, the method always returns true.

Let's assume that you set the following working time for the chart:

  • Working days: Monday - Friday
  • Working hours: 6:00 - 15:00

Then, if you check Monday April,3 2023 as in, you will get:

gantt.isWorkTime({date: new Date(2023,3,3,17,00), unit: "hour"}); 
//->false, потому что 17:00-18:00 не является рабочим временем

gantt.isWorkTime({date: new Date(2023,3,3,17,00), unit: "day"});
//-> true, потому что понедельник является рабочим днем

Configuration object properties

The configuration object can contain the following properties:

  • date - (Date) дата для проверки
  • unit - (string) optional, единица времени: "minute", "hour", "day", "week", "month", "year"
  • task - (object) optional, объект задачи, длительность которой должна быть рассчитана
if (gantt.isWorkTime({date: date, task: task})){
alert("worktime of task" + task.text);
}
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.