From 694ef721b62829cfc15f03569c7d176903244cbd Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 30 Jun 2022 09:49:32 +0800 Subject: [PATCH] MDL-74379 core: Update date_format_string to use x-os functions --- lib/moodlelib.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 86d02de6072..55ac1a58885 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2357,18 +2357,15 @@ function date_format_string($date, $format, $tz = 99) { date_default_timezone_set(core_date::get_user_timezone($tz)); - $datearray = getdate($date); - - if (nl_langinfo(AM_STR) == nl_langinfo(PM_STR)) { - + if (strftime('%p', 0) === strftime('%p', HOURSECS * 18)) { + $datearray = getdate($date); $format = str_replace([ '%P', '%p', ], [ $datearray['hours'] < 12 ? get_string('am', 'langconfig') : get_string('pm', 'langconfig'), $datearray['hours'] < 12 ? get_string('amcaps', 'langconfig') : get_string('pmcaps', 'langconfig'), - ], - $format); + ], $format); } $datestring = strftime($format, $date);