- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/processor/task/scheduler/result/impact.php
- Класс: BitrixTasksProcessorTaskSchedulerResultImpact
- Вызов: Impact::matchWorkingTime
private function matchWorkingTime(DateTime $startDate = null, Datetime $endDate = null, $duration = null)
{
if(!$this->getMatchWorkTime())
{
return; // do nothing, dates are okay already
}
else
{
$calendar = Calendar::getInstance();
if ($startDate && $endDate)
{
$this->correctWorkTime($startDate, $endDate, $duration);
}
elseif($startDate)
{
$this->setStartDatePlanUserTimeGmt($calendar->getClosestWorkTime($startDate, true)->toStringGmt());
$start = $this->getStartDatePlanGmt(true);
$end = $this->getEndDatePlanGmt();
if($end !== null && $start->checkGT($end))
{
$this->setEndDatePlanUserTimeGmt($calendar->calculateEndDate($startDate, $end->getTimestamp() - $startDate->getTimestamp())->toStringGmt());
}
}
elseif($endDate)
{
$this->setEndDatePlanUserTimeGmt($calendar->getClosestWorkTime($endDate, false)->toStringGmt());
$start = ($startDate == null? null : $this->getStartDatePlanGmt(true));
$end = $this->getEndDatePlanGmt();
if($start !== null && $start->checkGT($end))
{
$this->setStartDatePlanUserTimeGmt($calendar->calculateStartDate($end, $endDate->getTimestamp() - $start->getTimestamp())->toStringGmt());
}
}
}
}