CBPCalc::replaceDateToLocDate

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPCalc
  4. replaceDateToLocDate
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/calc.php
  • Класс: CBPCalc
  • Вызов: CBPCalc::replaceDateToLocDate
private function replaceDateToLocDate($formattedDate, $format)
{
	$lenShortName = 3;
	$dayNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
	$monthNames = [
		'January',
		'February',
		'March',
		'April',
		'May',
		'June',
		'July',
		'August',
		'September',
		'October',
		'November',
		'December',
	];

	if (strpos($format, '#r#') !== false)
	{
		$formattedDate = $this->frameNamesInFormattedDateRFC2822($formattedDate);
	}

	$replacementRule = [];
	foreach (array_merge($dayNames, $monthNames) as $name)
	{
		$replacementRule['#' . $name . '#'] = GetMessage(
			'BPCGCALC_LOCDATE_' . strtoupper($name)
		);
		$shortName = substr($name, 0, $lenShortName);
		$replacementRule['#' . $shortName . '#'] = GetMessage(
			'BPCGCALC_LOCDATE_' . strtoupper($shortName) . '_SHORT'
		);
	}
	foreach ($monthNames as $monthName)
	{
		$replacementRule['#' . $monthName . '_1' . '#'] = GetMessage(
			'BPCGCALC_LOCDATE_' . strtoupper($monthName) . '_1'
		);
	}

	return strtr($formattedDate, $replacementRule);
}

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