fixes #1897 use preg_match instead of deprecated strptime

This commit is contained in:
plegall 2023-10-05 15:37:48 +02:00
parent b01bf6ef3d
commit d050573d83

View file

@ -600,25 +600,14 @@ function get_title_recent_post_date($date_detail)
{
global $lang;
$date = $date_detail['date_available'];
$exploded_date = strptime($date, '%Y-%m-%d %H:%M:%S');
$title = l10n_dec('%d new photo', '%d new photos', $date_detail['nb_elements']);
$title .= ' ('.$lang['month'][1+$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';
if (preg_match('/^\d+-(\d+)-(\d+) /', $date_detail['date_available'], $matches))
{
$title .= ' ('.$lang['month'][(int)$matches[1]].' '.$matches[2].')';
}
return $title;
}
if (!function_exists('strptime'))
{
function strptime($date, $fmt)
{
if ($fmt != '%Y-%m-%d %H:%M:%S')
die('Invalid strptime format '.$fmt);
list($y,$m,$d,$H,$M,$S) = preg_split('/[-: ]/', $date);
$res = localtime( mktime($H,$M,$S,$m,$d,$y), true );
return $res;
}
}
?>