From aed39b73e529b325fcd9c3020fff6f97ffc500d5 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 15 Jan 2024 23:23:23 +0100 Subject: [PATCH] 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 --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/lib/functions2.lib.php | 2 +- htdocs/core/modules/facture/mod_facture_terre.php | 2 +- htdocs/core/modules/mrp/mod_mo_standard.php | 2 +- htdocs/core/modules/product_batch/mod_lot_standard.php | 2 +- htdocs/core/modules/product_batch/mod_sn_standard.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/stock/movement_card.php | 4 ++-- htdocs/product/stock/movement_list.php | 4 ++-- htdocs/projet/activity/index.php | 4 ++-- htdocs/salaries/card.php | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3282d916745..0786ea6db3c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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'; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index a07c7868c3c..292bbb82eaf 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -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' diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 95bc0dc27d2..f7937701a3b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -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 diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index c27c36c8849..72ea06d05ab 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -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 diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index f6b674cf3f6..b63aff30a84 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -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; diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index 42d55ff92b7..5f569baa498 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -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; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5a7ae18ee1d..d034d7ebd7d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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. diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 0416064f466..11c3dc31649 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -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); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 9a447d213db..d8cb47f17fe 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -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); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 8be73099cac..6d7f9656d73 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -327,7 +327,7 @@ if (getDolGlobalString('PROJECT_TASK_TIME_YEAR')) { print '
'; print '
'; print ''; - print ''; + print ''; print ''; print "\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"; diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 89442fa0b4c..bfb5cd7d357 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -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;
'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).''.$langs->trans("ActivityOnProjectThisYear").': '.dol_print_date($now, "%Y").''.$langs->trans("Time").'