Fix: PHP8.1 strftime deprecation -> dol_print_date

# Fix: PHP8.1 strftime deprecation -> dol_print_date

Change strftime to dol_print_date to work around deprecation
This commit is contained in:
MDW 2024-01-15 23:23:23 +01:00
parent 76f1b37d4f
commit aed39b73e5
11 changed files with 15 additions and 15 deletions

View File

@ -2781,7 +2781,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
function dol_strftime($fmt, $ts = false, $is_gmt = false)
{
if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
return ($is_gmt) ? @gmstrftime($fmt, $ts) : @dol_print_date($ts, $fmt);
} else {
return 'Error date into a not supported range';
}

View File

@ -1612,7 +1612,7 @@ function hexbin($hexa)
*/
function numero_semaine($time)
{
$stime = strftime('%Y-%m-%d', $time);
$stime = dol_print_date($time, '%Y-%m-%d');
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) {
// Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'

View File

@ -262,7 +262,7 @@ class mod_facture_terre extends ModeleNumRefFactures
return $ref;
} elseif ($mode == 'next') {
$date = $invoice->date; // This is invoice date (not creation date)
$yymm = strftime("%y%m", $date);
$yymm = dol_print_date($date, "%y%m");
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is

View File

@ -142,7 +142,7 @@ class mod_mo_standard extends ModeleNumRefMos
//$date=time();
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
$yymm = dol_print_date($date, "%y%m");
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is

View File

@ -144,7 +144,7 @@ class mod_lot_standard extends ModeleNumRefBatch
//$date=time();
$date = dol_now();
$yymm = strftime("%y%m", $date);
$yymm = dol_print_date($date, "%y%m");
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1;

View File

@ -144,7 +144,7 @@ class mod_sn_standard extends ModeleNumRefBatch
//$date=time();
$date = dol_now();
$yymm = strftime("%y%m", $date);
$yymm = dol_print_date($date, "%y%m");
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1;

View File

@ -3889,8 +3889,8 @@ class Product extends CommonObject
}
if (empty($year)) {
$year = strftime('%Y', time());
$month = strftime('%m', time());
$year = dol_print_date(time(), '%Y');
$month = dol_print_date(time(), '%m');
} elseif ($year == -1) {
$year = '';
$month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year.

View File

@ -1146,8 +1146,8 @@ if ($resql) {
$productidselected = $key;
$productlabelselected = $val;
}
$datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true);
$dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true);
$datebefore = dol_get_first_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 1, true);
$dateafter = dol_get_last_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 12, true);
$balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
$balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);

View File

@ -1641,8 +1641,8 @@ if (count($arrayofuniqueproduct) == 1 && !empty($year) && is_numeric($year)) {
$productidselected = $key;
$productlabelselected = $val;
}
$datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true);
$dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true);
$datebefore = dol_get_first_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 1, true);
$dateafter = dol_get_last_day($year ? $year : dol_print_date(time(), "%Y"), $month ? $month : 12, true);
$balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore);
$balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter);

View File

@ -327,7 +327,7 @@ if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) {
print '<div class="div-table-responsive-no-min">';
print '<br><table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).'</td>';
print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.dol_print_date($now, "%Y").'</td>';
print '<td class="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
@ -340,7 +340,7 @@ if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) {
$sql .= " AND tt.fk_element = t.rowid";
$sql .= " AND tt.elementtype = 'task'";
$sql .= " AND tt.fk_user = ".((int) $user->id);
$sql .= " AND YEAR(element_date) = '".strftime("%Y", $now)."'";
$sql .= " AND YEAR(element_date) = '".dol_print_date($now, "%Y")."'";
$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";

View File

@ -496,7 +496,7 @@ if ($id > 0) {
// Create
if ($action == 'create' && $permissiontoadd) {
$year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonth = dol_print_date(dol_now(), "%m") - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;