From 437d5e135265dc0556211d274df16c15c8855e0e Mon Sep 17 00:00:00 2001 From: campi Date: Fri, 25 Nov 2022 00:54:38 +0100 Subject: [PATCH] fixed have_to_run method --- shortcodes/palinsesto.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shortcodes/palinsesto.php b/shortcodes/palinsesto.php index 0546ce1..ac17b08 100644 --- a/shortcodes/palinsesto.php +++ b/shortcodes/palinsesto.php @@ -9,11 +9,11 @@ function have_to_run_this_week($start_date, $cadence) break; case 2: case 4: - $date = getdate(strtotime($start_date)); - $today = getdate(date("U")); + $today = new DateTime(); + $date = new DateTime($start_date); $modulo = 7 * $cadence; $date_difference = date_diff($today, $date); - $days_difference = $date_difference["days"]; + $days_difference = $date_difference->days; if (($days_difference % $modulo) < 7) { $return_value = true; break; @@ -21,8 +21,8 @@ function have_to_run_this_week($start_date, $cadence) $return_value = false; break; } - - return $return_value + + return $return_value; } function show_palinsesto($args) @@ -78,7 +78,7 @@ function show_palinsesto($args) $rerun_start_date = get_post_meta($post->ID, 'rerun_start_date_'.$d, true); if (empty($rerun_cadence) || empty($rerun_start_date)) { - $rerun_cadence = "1"; + $rerun_cadence = "1"; //default settimanale } if (!empty($rerun_day)&&!empty($rerun_start)&&!empty($rerun_end)) {