Fixed date logic

master
root 9 months ago
parent 20f9cdd4fe
commit 47a74fad13
  1. 4
      gen_vor.php

@ -30,6 +30,7 @@ if ($first_wedn->format('md') == '0301') {
}
$tues_ts = strtotime($number . ' tuesday of this month', $ts);
$tues_date = (new DateTime())->setTimeStamp($tues_ts);
$wed_ts = strtotime('next day', $tues_ts);
const JUST_DATE = 'Ymd';
@ -38,10 +39,11 @@ $month = $first_day->format('n');
$cond = true;
if ($month == 2 || $month == 3) {
$cond = $first_day->format(JUST_DATE) != $first_wedn->format(JUST_DATE) && $tues_date->format('md') != '0322';
printf('Cond: %d\n', $cond);
}
// Are we past the fourth Tuesday of this month?
if ((new DateTime())->getTimeStamp() >= $tues_ts && $cond) {
if ((new DateTime())->getTimeStamp() >= $wed_ts && $cond) {
$ts = strtotime('+1 month', $ts);
/*
var_dump($tues_date->format('md'));

Loading…
Cancel
Save