Clean deprecated code for adodbtime
This commit is contained in:
parent
0db5c98941
commit
c593d990e4
@ -2647,12 +2647,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
$format = str_replace('%A', '__A__', $format);
|
$format = str_replace('%A', '__A__', $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
$useadodb = getDolGlobalInt('MAIN_USE_LEGACY_ADODB_FOR_DATE', 0);
|
|
||||||
//$useadodb = 1; // To switch to adodb
|
|
||||||
if (!empty($useadodb)) {
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/includes/adodbtime/adodb-time.inc.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analyze date
|
// Analyze date
|
||||||
$reg = array();
|
$reg = array();
|
||||||
if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
|
if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
|
||||||
@ -2671,7 +2665,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
$ssec = (!empty($reg[6]) ? $reg[6] : '');
|
$ssec = (!empty($reg[6]) ? $reg[6] : '');
|
||||||
|
|
||||||
$time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true);
|
$time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true);
|
||||||
if (empty($useadodb)) {
|
|
||||||
if ($to_gmt) {
|
if ($to_gmt) {
|
||||||
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
||||||
} else {
|
} else {
|
||||||
@ -2688,16 +2682,13 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
$ret = str_replace(
|
$ret = str_replace(
|
||||||
array('__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
|
array('__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
|
||||||
array('T', 'Z', '__a__', '__A__', '__b__', '__B__'),
|
array('T', 'Z', '__a__', '__A__', '__b__', '__B__'),
|
||||||
$ret);
|
$ret
|
||||||
} else {
|
);
|
||||||
$ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Date is a timestamps
|
// Date is a timestamps
|
||||||
if ($time < 100000000000) { // Protection against bad date values
|
if ($time < 100000000000) { // Protection against bad date values
|
||||||
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
|
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
|
||||||
|
|
||||||
if (empty($useadodb)) {
|
|
||||||
if ($to_gmt) {
|
if ($to_gmt) {
|
||||||
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
||||||
} else {
|
} else {
|
||||||
@ -2714,10 +2705,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
$ret = str_replace(
|
$ret = str_replace(
|
||||||
array('__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
|
array('__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
|
||||||
array('T', 'Z', '__a__', '__A__', '__b__', '__B__'),
|
array('T', 'Z', '__a__', '__A__', '__b__', '__B__'),
|
||||||
$ret);
|
$ret
|
||||||
} else {
|
);
|
||||||
$ret = adodb_strftime($format, $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server
|
|
||||||
}
|
|
||||||
//var_dump($ret);exit;
|
//var_dump($ret);exit;
|
||||||
} else {
|
} else {
|
||||||
$ret = 'Bad value '.$time.' for date';
|
$ret = 'Bad value '.$time.' for date';
|
||||||
@ -2727,7 +2716,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
if (preg_match('/__b__/i', $format)) {
|
if (preg_match('/__b__/i', $format)) {
|
||||||
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
|
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
|
||||||
|
|
||||||
if (empty($useadodb)) {
|
|
||||||
if ($to_gmt) {
|
if ($to_gmt) {
|
||||||
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
||||||
} else {
|
} else {
|
||||||
@ -2737,10 +2725,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
$dtts->setTimestamp($timetouse);
|
$dtts->setTimestamp($timetouse);
|
||||||
$dtts->setTimezone($tzo);
|
$dtts->setTimezone($tzo);
|
||||||
$month = $dtts->format("m");
|
$month = $dtts->format("m");
|
||||||
} else {
|
|
||||||
// After this ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs.
|
|
||||||
$month = adodb_strftime('%m', $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server
|
|
||||||
}
|
|
||||||
$month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
|
$month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
|
||||||
if ($encodetooutput) {
|
if ($encodetooutput) {
|
||||||
$monthtext = $outputlangs->transnoentities('Month'.$month);
|
$monthtext = $outputlangs->transnoentities('Month'.$month);
|
||||||
@ -2759,7 +2743,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
//print "time=$time offsettz=$offsettz offsetdst=$offsetdst offsettzstring=$offsettzstring";
|
//print "time=$time offsettz=$offsettz offsetdst=$offsetdst offsettzstring=$offsettzstring";
|
||||||
$timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
|
$timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
|
||||||
|
|
||||||
if (empty($useadodb)) {
|
|
||||||
if ($to_gmt) {
|
if ($to_gmt) {
|
||||||
$tzo = new DateTimeZone('UTC');
|
$tzo = new DateTimeZone('UTC');
|
||||||
} else {
|
} else {
|
||||||
@ -2769,9 +2752,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
$dtts->setTimestamp($timetouse);
|
$dtts->setTimestamp($timetouse);
|
||||||
$dtts->setTimezone($tzo);
|
$dtts->setTimezone($tzo);
|
||||||
$w = $dtts->format("w");
|
$w = $dtts->format("w");
|
||||||
} else {
|
|
||||||
$w = adodb_strftime('%w', $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server
|
|
||||||
}
|
|
||||||
$dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w);
|
$dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w);
|
||||||
|
|
||||||
$ret = str_replace('__A__', $dayweek, $ret);
|
$ret = str_replace('__A__', $dayweek, $ret);
|
||||||
|
|||||||
@ -395,7 +395,7 @@ class PartnershipUtils
|
|||||||
/**
|
/**
|
||||||
* Action to check if Dolibarr backlink not found on partner website
|
* Action to check if Dolibarr backlink not found on partner website
|
||||||
*
|
*
|
||||||
* @param $website Website Partner's website
|
* @param string $website Partner's website URL
|
||||||
* @return int 0 if KO, 1 if OK
|
* @return int 0 if KO, 1 if OK
|
||||||
*/
|
*/
|
||||||
private function checkDolibarrBacklink($website = null)
|
private function checkDolibarrBacklink($website = null)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user