fixed have_to_run method

master
campi 2 years ago
parent 758d5113ed
commit 437d5e1352

@ -9,11 +9,11 @@ function have_to_run_this_week($start_date, $cadence)
break; break;
case 2: case 2:
case 4: case 4:
$date = getdate(strtotime($start_date)); $today = new DateTime();
$today = getdate(date("U")); $date = new DateTime($start_date);
$modulo = 7 * $cadence; $modulo = 7 * $cadence;
$date_difference = date_diff($today, $date); $date_difference = date_diff($today, $date);
$days_difference = $date_difference["days"]; $days_difference = $date_difference->days;
if (($days_difference % $modulo) < 7) { if (($days_difference % $modulo) < 7) {
$return_value = true; $return_value = true;
break; break;
@ -22,7 +22,7 @@ function have_to_run_this_week($start_date, $cadence)
break; break;
} }
return $return_value return $return_value;
} }
function show_palinsesto($args) 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); $rerun_start_date = get_post_meta($post->ID, 'rerun_start_date_'.$d, true);
if (empty($rerun_cadence) || empty($rerun_start_date)) { 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)) { if (!empty($rerun_day)&&!empty($rerun_start)&&!empty($rerun_end)) {

Loading…
Cancel
Save