diff --git a/ChangeLog b/ChangeLog index 1c9578507eb..46f482aeab9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -114,6 +114,7 @@ For developers: - New: Add PRODUCT_PRICE_MODIFY trigger. - New: Created function to retrieve total amount of discount of an invoice/proposal... - New: We can use a dynamic value ($conf->global->XXX for example) into titles of menus. +- New: Use PHP classes DateTime* for some data functions instead of adodb - Qual: Renamed SUPPLIER_INVOICE_BUILDDOC trigger to BILL_SUPPLIER_BUILDDOC - Qual: Renamed INVOICE_SUPPLIER_DELETE trigger to BILL_SUPPLIER_DELETE - Qual: Renamed SUPLIER_ORDER_BUILDDOC trigger to ORDER_SUPPLIER_BUILDDOC diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 921cfa392a1..c7a7e1240dd 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -88,7 +88,7 @@ function getServerTimeZoneInt($refgmtdate='now') // Method 1 (include daylight) $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d'); if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref; - elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-05-15'; + elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01'; else $newrefgmtdate=$yearref.'-01-01'; $localtz = new DateTimeZone(getServerTimeZoneString()); $localdt = new DateTime($newrefgmtdate, $localtz); @@ -773,7 +773,7 @@ function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $ha global $langs; dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday); - + // Check parameters if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 4fd8452f970..b00fa11945a 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -116,27 +116,32 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface if (defined("SYSLOG_FILE_NO_ERROR")) $filefd = @fopen($logfile, 'a+'); else $filefd = fopen($logfile, 'a+'); - if (!$filefd && ! defined("SYSLOG_FILE_NO_ERROR")) + if (! $filefd) { - // Do not break dolibarr usage if log fails - //throw new Exception('Failed to open log file '.basename($logfile)); - print 'Failed to open log file '.basename($logfile); + if (! defined("SYSLOG_FILE_NO_ERROR")) + { + // Do not break dolibarr usage if log fails + //throw new Exception('Failed to open log file '.basename($logfile)); + print 'Failed to open log file '.basename($logfile); + } } + else + { + $logLevels = array( + LOG_EMERG => 'EMERG', + LOG_ALERT => 'ALERT', + LOG_CRIT => 'CRIT', + LOG_ERR => 'ERR', + LOG_WARNING => 'WARNING', + LOG_NOTICE => 'NOTICE', + LOG_INFO => 'INFO', + LOG_DEBUG => 'DEBUG' + ); - $logLevels = array( - LOG_EMERG => 'EMERG', - LOG_ALERT => 'ALERT', - LOG_CRIT => 'CRIT', - LOG_ERR => 'ERR', - LOG_WARNING => 'WARNING', - LOG_NOTICE => 'NOTICE', - LOG_INFO => 'INFO', - LOG_DEBUG => 'DEBUG' - ); + $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-5s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; - $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-5s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; - - fwrite($filefd, $message."\n"); - fclose($filefd); + fwrite($filefd, $message."\n"); + fclose($filefd); + } } } \ No newline at end of file