Merge branch 'MDL-76470-master' of https://github.com/marinaglancy/moodle

This commit is contained in:
Andrew Nicols 2022-11-25 08:06:11 +08:00
commit b38e0e9db4

View File

@ -708,6 +708,13 @@ class core_date {
* @author BohwaZ <https://bohwaz.net/>
*/
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;