CBPHelper::formatTimePeriod

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPHelper
  4. formatTimePeriod
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/helper.php
  • Класс: CBPHelper
  • Вызов: CBPHelper::formatTimePeriod
static function formatTimePeriod($period)
{
	$period = intval($period);

	$days = intval($period / 86400);
	$period = $period - $days * 86400;

	$hours = intval($period / 3600);
	$period = $period - $hours * 3600;

	$minutes = intval($period / 60);
	$period = $period - $minutes * 60;

	$seconds = intval($period);

	$s = "";
	if ($days > 0)
	{
		$s .= str_replace(
			array("#VAL#", "#UNIT#"),
			array($days, self::MakeWord($days, array(GetMessage("BPCGHLP_DAY1"), GetMessage("BPCGHLP_DAY2"), GetMessage("BPCGHLP_DAY3")))),
			"#VAL# #UNIT# "
		);
	}
	if ($hours > 0)
	{
		$s .= str_replace(
			array("#VAL#", "#UNIT#"),
			array($hours, self::MakeWord($hours, array(GetMessage("BPCGHLP_HOUR1"), GetMessage("BPCGHLP_HOUR2"), GetMessage("BPCGHLP_HOUR3")))),
			"#VAL# #UNIT# "
		);
	}
	if ($minutes > 0)
	{
		$s .= str_replace(
			array("#VAL#", "#UNIT#"),
			array($minutes, self::MakeWord($minutes, array(GetMessage("BPCGHLP_MIN1"), GetMessage("BPCGHLP_MIN2"), GetMessage("BPCGHLP_MIN3")))),
			"#VAL# #UNIT# "
		);
	}
	if ($seconds > 0)
	{
		$s .= str_replace(
			array("#VAL#", "#UNIT#"),
			array($seconds, self::MakeWord($seconds, array(GetMessage("BPCGHLP_SEC1"), GetMessage("BPCGHLP_SEC2"), GetMessage("BPCGHLP_SEC3")))),
			"#VAL# #UNIT# "
		);
	}

	return $s;
}

Добавить комментарий