MDL-76537 core: Fix date_format_string() to work with php-intl

With Moodle 4.1 and up, we have stopped to work with strftime(),
because it's deprecated for PHP 8.1 and up and, instead we are
using core_date::strftime() that performs the conversions using
the php-intl extension.

The original strftime() had a lot of OS-specific dependencies,
both about locale names and charsets used to provide the information.

Instead, the php-intl gets rid of all those OS-specific nightmares
and only uses ICU/Unicode locales and UTF-8.

Because of that, the old utf-8 => windows charset => utf-8
conversions aren't needed anymore. Hence, removing them.
This commit is contained in:
Eloy Lafuente (stronk7) 2022-12-23 00:01:26 +01:00
parent 5dbac075be
commit 7827edc78d

View File

@ -2362,18 +2362,6 @@ function userdate_htmltime($date, $format = '', $timezone = 99, $fixday = true,
* @since Moodle 2.3.3
*/
function date_format_string($date, $format, $tz = 99) {
global $CFG;
$localewincharset = null;
// Get the calendar type user is using.
if ($CFG->ostype == 'WINDOWS') {
$calendartype = \core_calendar\type_factory::get_calendar_instance();
$localewincharset = $calendartype->locale_win_charset();
}
if ($localewincharset) {
$format = core_text::convert($format, 'utf-8', $localewincharset);
}
date_default_timezone_set(core_date::get_user_timezone($tz));
@ -2391,10 +2379,6 @@ function date_format_string($date, $format, $tz = 99) {
$datestring = core_date::strftime($format, $date);
core_date::set_default_server_timezone();
if ($localewincharset) {
$datestring = core_text::convert($datestring, $localewincharset, 'utf-8');
}
return $datestring;
}