27 if (extension_loaded(
'intl')) {
34 elgg_log(
"Unable to generate locale representation for format: '{$format}', using non-locale version",
'INFO');
35 return $this->format($format);
55 if (
preg_match(
'/(?<!\\|%)[ntLBueIPZcr]/', $dateFormat)) {
62 'd' =>
'%d',
'D' =>
'%a',
'j' =>
'%e',
'l' =>
'%A',
'N' =>
'%u',
'w' =>
'%w',
'z' =>
'%j',
66 'F' =>
'%B',
'm' =>
'%m',
'M' =>
'%b',
68 'o' =>
'%G',
'Y' =>
'%Y',
'y' =>
'%y',
70 'a' =>
'%P',
'A' =>
'%p',
'g' =>
'%l',
'h' =>
'%I',
'H' =>
'%H',
'i' =>
'%M',
's' =>
'%S',
72 'O' =>
'%z',
'T' =>
'%Z',
82 return strtr((
string) $dateFormat, $caracs);
97 if ($correct_format ===
false) {
101 if (version_compare(PHP_VERSION,
'8.1.0',
'>=')) {
102 elgg_log(
'In order to get rid of the deprecated warnings about strftime() enable the "intl" PHP module',
'WARNING');
106 $current_locale =
_elgg_services()->locale->setLocaleFromLanguageKey(LC_TIME, $language);
108 $result = strftime($correct_format, $this->getTimestamp());
126 if (
preg_match(
'/(?<!\\|%)[BcILrtuUVZ]/', $dateFormat)) {
133 'd' =>
'dd',
'D' =>
'EEE',
'j' =>
'd',
'l' =>
'EEEE',
'N' =>
'e',
'w' =>
'c',
'z' =>
'D',
137 'F' =>
'MMMM',
'm' =>
'MM',
'M' =>
'MMM',
'n' =>
'M',
139 'o' =>
'Y',
'Y' =>
'yyyy',
'y' =>
'yy',
141 'a' =>
'a',
'A' =>
'a',
'g' =>
'h',
'G' =>
'H',
'h' =>
'hh',
'H' =>
'HH',
'i' =>
'mm',
's' =>
'ss',
143 'e' =>
'VV',
'O' =>
'xx',
'P' =>
'xxx',
'p' =>
'XXX',
'T' =>
'zzz',
149 return strtr((
string) $dateFormat, $caracs);
163 if ($correct_format ===
false) {
167 $locale_for_language =
_elgg_services()->locale->getLocaleForLanguage($language);
169 $locale = new \IntlDateFormatter(
elgg_extract(0, $locale_for_language, $language), \IntlDateFormatter::FULL, \IntlDateFormatter::FULL);
170 $locale->setPattern($correct_format);
172 return $locale->format($this);
formatIntl(string $format, string $language)
Try to format to a locale using the 'intl' PHP module.
dateFormatToICU(string $dateFormat)
Convert a date format to a ICU format.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
formatLocale(string $format, string $language=null)
Try to format the date using locale output.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
formatStrftime(string $format, string $language)
Try to format to a locale using strftime()
_elgg_services()
Get the global service provider.
dateFormatToStrftime(string $dateFormat)
Convert a date format to a strftime format.