• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/compatible/internals/entitycompatibility.php
  • Класс: BitrixSaleCompatibleInternalsEntityCompatibility
  • Вызов: EntityCompatibility::convertDateField
static function convertDateField($name, $value, array $dateFields = array())
{
	$key = $name;
	if (mb_substr($key, 0, 1) == '=')
	{
		$key = mb_substr($key, 1);
	}

	if (!array_key_exists($key, $dateFields))
	{
		return $value;
	}

	$nowDate = Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction();

	if (!($value instanceof DateTime)
		&& !($value instanceof Date))
	{
		if ($value === null)
			return null;

		if (strval($value) == '')
			return false;


		$setValue = null;

		if (ToLower($value) != ToLower($nowDate))
		{
			$setValue = $value;
		}

		if (ToUpper($dateFields[$key]) == "DATE")
		{
			$value = new Date($setValue);
		}
		elseif (ToUpper($dateFields[$key]) == "DATETIME")
		{
			$value = new DateTime($setValue);
		}
	}

	return $value;
}