Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Crash DateTime::setTimestamp() #19210

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -2288,6 +2288,11 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = '', $encodetooutput = false)
{
global $conf, $langs;
// If date undefined or "", we return ""
// Must be tested before line $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : $time);
if (dol_strlen($time) == 0) {
return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
}

if ($tzoutput === 'auto') {
$tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver'));
Expand Down Expand Up @@ -2380,11 +2385,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
$format = str_replace('yyyy', 'yy', $format);
}

// If date undefined or "", we return ""
if (dol_strlen($time) == 0) {
return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
}

// Clean format
if (preg_match('/%b/i', $format)) { // There is some text to translate
// We inhibate translation to text made by strftime functions. We will use trans instead later.
Expand Down