• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/integration/report/handler/base.php
  • Класс: BitrixVoximplantIntegrationReportHandlerBase
  • Вызов: Base::formatDuration
public function formatDuration($duration)
{
	if ($duration == null)
	{
		return 0;
	}

	$duration = (int)$duration;
	$hours = floor($duration / 3600);
	$minutes = floor($duration / 60) - ($hours * 60);
	$seconds = $duration % 60;

	$text = '';
	if ($hours > 0)
	{
		$text = $hours .' '. Loc::getMessage('TELEPHONY_REPORT_BASE_HOUR');
	}

	if ($minutes > 0)
	{
		$minutesText = $minutes .' '. Loc::getMessage('TELEPHONY_REPORT_BASE_MIN');
		$text .= ($text === '' ? $minutesText : ', ' . $minutesText);
	}
	elseif ($seconds > 0)
	{
		$secondsText = $seconds .' '. Loc::getMessage('TELEPHONY_REPORT_BASE_SEC');
		$text .= ($text === '' ? $secondsText : ', ' . $secondsText);
	}

	return $text;
}