• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/util/replicator/task/fromtask.php
  • Класс: BitrixTasksUtilReplicatorTaskFromTask
  • Вызов: FromTask::processDates
private function processDates(array $taskData): array
{
	$result = [];

	/** @var DateTime $createdDate */
	$createdDate = clone $taskData['CREATED_DATE'];
	$createdDate->stripTime();

	$dates = [
		'DEADLINE',
		'START_DATE_PLAN',
		'END_DATE_PLAN',
	];
	foreach ($dates as $key)
	{
		if ($taskData[$key])
		{
			/** @var DateTime $dateDate */
			$dateDate = clone $taskData[$key];
			$dateDate->stripTime();

			$diff = $createdDate->getDiff($dateDate);
			$daysDiff = $diff->format('%d');
			$daysDiff = ($diff->invert ? -$daysDiff : +$daysDiff);

			($now = new DateTime())->addDay($daysDiff);

			/** @var DateTime $newDate */
			$newDate = clone $taskData[$key];
			$newDate->setDate(
				$now->getYearGmt(),
				$now->getMonthGmt(),
				$now->getDayGmt()
			);

			$result[$key] = $newDate;
		}
	}

	return $result;
}