• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/integration/report/handler/base.php
  • Класс: BitrixVoximplantIntegrationReportHandlerBase
  • Вызов: Base::getPreviousPeriod
protected function getPreviousPeriod(Date $from, Date $to): array
{
	$difference = $to->getTimestamp() - $from->getTimestamp();

	if($difference < 0)
	{
		throw new ArgumentException("Date from should be earlier than date to");
	}

	$to = clone $from;
	$to->add('-1 second');
	$fromTimestamp = $from->getTimestamp() - $difference;
	$from = Date::createFromTimestamp($fromTimestamp);

	return ['from' => $from, 'to' => $to, 'diff' => $difference];
}