• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/integration/main/culture.php
  • Класс: BitrixIntranetIntegrationMainCulture
  • Вызов: Culture::updateCulture
static function updateCulture($fields)
{
	$newFields = [];
	$currentCulture = MainContext::getCurrent()->getCulture();
	if (isset($fields['TIME_FORMAT_TYPE']))
	{
		$type = (int) $fields['TIME_FORMAT_TYPE'];

		$defaultCulture = self::getDefaultCulture(MainContext::getCurrent()->getLanguage());

		$formatDate = $currentCulture->getFormatDate();
		if ($type === 12)
		{
			if (strpos($currentCulture->getFormatDatetime(), ' H:MI:SS T') === false)
			{
				$newFields['FORMAT_DATETIME'] = $formatDate . ' H:MI:SS T';
			}
			if ($currentCulture->getShortTimeFormat() !== 'g:i a')
			{
				$newFields['SHORT_TIME_FORMAT'] = 'g:i a';
			}
			if ($currentCulture->getLongTimeFormat() !== 'g:i:s a')
			{
				$newFields['LONG_TIME_FORMAT'] = 'g:i:s a';
			}
		}
		else
		{
			if (strpos($currentCulture->getFormatDatetime(), ' HH:MI:SS') === false)
			{
				$newFields['FORMAT_DATETIME'] = $formatDate . ' HH:MI:SS';
			}

			if ($currentCulture->getShortTimeFormat() === 'g:i a')
			{
				if (mb_strpos($defaultCulture['SHORT_TIME_FORMAT'], 'H') === false
					&& mb_strpos($defaultCulture['SHORT_TIME_FORMAT'], 'G') === false)
				{
					$newFields['SHORT_TIME_FORMAT'] = 'G:i';
				}
				else
				{
					$newFields['SHORT_TIME_FORMAT'] = $defaultCulture['SHORT_TIME_FORMAT'];
				}
			}
			if ($currentCulture->getLongTimeFormat() === 'g:i:s a')
			{
				if (mb_strpos($defaultCulture['LONG_TIME_FORMAT'], 'H') === false
					&& mb_strpos($defaultCulture['LONG_TIME_FORMAT'], 'G') === false)
				{
					$newFields['LONG_TIME_FORMAT'] = 'G:i:s';
				}
				else
				{
					$newFields['LONG_TIME_FORMAT'] = $defaultCulture['LONG_TIME_FORMAT'];
				}
			}
		}
	}

	if (isset($fields['WEEK_START']) && (int) $currentCulture->getWeekStart() !== (int) $fields['WEEK_START'])
	{
		$newFields['WEEK_START'] = $fields['WEEK_START'];
	}

	if (isset($fields['FORMAT_NAME']) && $currentCulture->getFormatName() !== $fields['FORMAT_NAME'])
	{
		$newFields['FORMAT_NAME'] = $fields['FORMAT_NAME'];
	}

	if (sizeof($newFields) > 0)
	{
		CultureTable::update($currentCulture->getId(), $newFields);
	}
}