mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-76470 core: normalise locale for strftime substitution
Huge thanks to Eloy Lafuente for investigation
This commit is contained in:
parent
4e95640030
commit
6fb9209405
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user