• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
  • Класс: CCalendar
  • Вызов: CCalendar::GetFromToHtml
static function GetFromToHtml($fromTs = false, $toTs = false, $skipTime = false, $dtLength = 0, $forRrule = false)
{
	if ((int)$fromTs != $fromTs)
	{
		$fromTs = self::Timestamp($fromTs);
	}
	if ((int)$toTs != $toTs)
	{
		$toTs = self::Timestamp($toTs);
	}
	if ($toTs < $fromTs)
	{
		$toTs = $fromTs;
	}

	// Formats
	$formatShort = self::DFormat(false);
	$formatFull = self::DFormat(true);
	$formatTime = str_replace($formatShort, '', $formatFull);
	$formatTime = $formatTime == $formatFull ? "H:i" : str_replace(':s', '', $formatTime);
	$html = '';

	$formatFull = str_replace(':s', '', $formatFull);

	if ($skipTime)
	{
		if ($dtLength == self::DAY_LENGTH || !$dtLength) // One full day event
		{
			if (!$forRrule)
			{
				$html = FormatDate(array(
					"tommorow" => "tommorow",
					"today" => "today",
					"yesterday" => "yesterday",
					"-" => $formatShort,
					"" => $formatShort,
				), $fromTs, time() + CTimeZone::GetOffset());
				$html .= ', ';
			}

			$html .= Loc::getMessage('EC_VIEW_FULL_DAY');
		}
		else // Event for several days
		{
			$from = FormatDate(array(
				"tommorow" => "tommorow",
				"today" => "today",
				"yesterday" => "yesterday",
				"-" => $formatShort,
				"" => $formatShort,
			), $fromTs, time() + CTimeZone::GetOffset());

			$to = FormatDate(array(
				"tommorow" => "tommorow",
				"today" => "today",
				"yesterday" => "yesterday",
				"-" => $formatShort,
				"" => $formatShort,
			), $toTs - self::DAY_LENGTH, time() + CTimeZone::GetOffset());

			$html = Loc::getMessage('EC_VIEW_DATE_FROM_TO', array('#DATE_FROM#' => $from, '#DATE_TO#' => $to));
		}
	}
	else
	{
		// Event during one day
		if(date('dmY', $fromTs) == date('dmY', $toTs))
		{
			if (!$forRrule)
			{
				$html = FormatDate(array(
					"tommorow" => "tommorow",
					"today" => "today",
					"yesterday" => "yesterday",
					"-" => $formatShort,
					"" => $formatShort,
				), $fromTs, time() + CTimeZone::GetOffset());
				$html .= ', ';
			}

			$html .= Loc::getMessage('EC_VIEW_TIME_FROM_TO_TIME', array('#TIME_FROM#' => FormatDate($formatTime, $fromTs), '#TIME_TO#' => FormatDate($formatTime, $toTs)));
		}
		else
		{
			$html = Loc::getMessage('EC_VIEW_DATE_FROM_TO', array('#DATE_FROM#' => FormatDate($formatFull, $fromTs, time() + CTimeZone::GetOffset()), '#DATE_TO#' => FormatDate($formatFull, $toTs, time() + CTimeZone::GetOffset())));
		}
	}

	return $html;
}