• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/update/timemanversion18user.php
  • Класс: BitrixTimemanUpdateTimemanVersion18User
  • Вызов: TimemanVersion18User::MakeShortTS
static function MakeShortTS($time)
{
	static $arCoefs = [3600, 60, 1];

	if ($time === intval($time))
	{
		return $time % 86400;
	}

	$amPmTime = explode(' ', $time);
	if (count($amPmTime) > 1)
	{
		$time = $amPmTime[0];
		$mt = $amPmTime[1];
	}

	$arValues = explode(':', $time);

	$cnt = count($arValues);
	if ($cnt <= 1)
	{
		return 0;
	}
	elseif ($cnt <= 2)
	{
		$arValues[] = 0;
	}

	// if time as AmPm
	if (!empty($mt) && strcasecmp($mt, 'pm') === 0)
	{
		if ($arValues[0] < 12)
		{
			$arValues[0] = $arValues[0] + 12;
		}
	}

	$ts = 0;
	for ($i = 0; $i < 3; $i++)
	{
		$ts += intval($arValues[$i] * $arCoefs[$i]);
	}

	return $ts % 86400;
}