• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/handler/taskfieldhandler.php
  • Класс: BitrixTasksControlHandlerTaskFieldHandler
  • Вызов: TaskFieldHandler::prepareDates
public function prepareDates(): self
{
	$this->checkDatesInProject();

	$startDate = ($this->fields['START_DATE_PLAN'] ?? null);
	$endDate = ($this->fields['END_DATE_PLAN'] ?? null);

	// you are not allowed to clear up END_DATE_PLAN while the task is linked
	if (
		$this->taskId
		&& isset($endDate)
		&& (string)$endDate === ''
		&& ProjectDependenceTable::checkItemLinked($this->taskId)
	)
	{
		throw new TaskFieldValidateException(Loc::getMessage('TASKS_IS_LINKED_END_DATE_PLAN_REMOVE'));
	}

	if (
		isset($startDate, $endDate)
		&& $startDate !== ''
		&& $endDate !== ''
	)
	{
		$startDateTs = MakeTimeStamp($startDate);
		$endDateTs = MakeTimeStamp($endDate);

		if ($startDateTs > 0 && $endDateTs > 0)
		{
			if ($endDateTs < $startDateTs)
			{
				throw new TaskFieldValidateException(Loc::getMessage('TASKS_BAD_PLAN_DATES'));
			}
			if ($endDateTs - $startDateTs > CTasks::MAX_INT)
			{
				throw new TaskFieldValidateException(Loc::getMessage('TASKS_BAD_DURATION'));
			}
		}
	}

	if ($this->taskId)
	{
		return $this;
	}

	if (!isset($this->fields['CREATED_DATE']))
	{
		$this->fields['CREATED_DATE'] = BitrixTasksUI::formatDateTime(UtilUser::getTime());
	}

	if (
		isset($this->fields['DEADLINE'])
		&& (string) $this->fields['DEADLINE'] != ''
		&& isset($this->fields['MATCH_WORK_TIME'])
		&& $this->fields['MATCH_WORK_TIME'] == 'Y'
	)
	{
		$this->fields['DEADLINE'] = $this->getDeadlineMatchWorkTime($this->fields['DEADLINE']);
	}

	return $this;
}