diff --git a/lib/classes/date.php b/lib/classes/date.php index bde01d29b05..14e178ddddc 100644 --- a/lib/classes/date.php +++ b/lib/classes/date.php @@ -708,6 +708,13 @@ class core_date { * @author BohwaZ */ public static function strftime(string $format, $timestamp = null, ?string $locale = null) : string { + // Moodle-specific modification. For the IntlDateFormatter we need to use unix-style locale + // from the string 'locale' even for Windows, so we can neither use moodle_getlocale(). + // nor rely on the setlocale() use below. We also ignore $CFG->locale because it can use + // Windows format. + $locale = $locale ?: get_string('locale', 'langconfig'); + + // The following code is taken from https://github.com/alphp/strftime without modifications. // phpcs:disable if (!($timestamp instanceof DateTimeInterface)) { $timestamp = is_int($timestamp) ? '@' . $timestamp : (string) $timestamp;