Skip to content

Commit

Permalink
MDL-74379 core: Update date_format_string to use x-os functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 30, 2022
1 parent fe88f32 commit 4fd50e8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/moodlelib.php
Expand Up @@ -2354,18 +2354,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);
Expand Down

0 comments on commit 4fd50e8

Please sign in to comment.