diff --git a/gen_vor.php b/gen_vor.php index 2351e5e..7928a1d 100644 --- a/gen_vor.php +++ b/gen_vor.php @@ -20,20 +20,25 @@ $file_md = 'vor.md'; $fil = file($file_txt, FILE_IGNORE_NEW_LINES); // Insert header $arr = ['| | | |', '|:------|:------|:------|']; -$ts=(new DateTime('first day of this month'))->getTimeStamp(); +$first_day = new DateTime('first day of this month'); +$ts = $first_day->getTimeStamp(); $first_wedn = new DateTime('first wednesday of this month'); -$wednesday = 'fourth'; +$number = 'fourth'; // Treat March differently if ($first_wedn->format('md') == '0301') { - $wednesday = 'fifth'; + $number = 'fifth'; } -$tues_ts = strtotime($wednesday . ' wednesday of this month', $ts); +$tues_ts = strtotime($number . ' tuesday of this month', $ts); $tues_date = (new DateTime())->setTimeStamp($tues_ts); +const JUST_DATE = 'Ymd'; + // Are we past the fourth Tuesday of this month? -if ((new DateTime())->getTimeStamp() >= $tues_ts && $tues_date->format('md') != '0322') { +if ((new DateTime())->getTimeStamp() >= $tues_ts && $first_day->format(JUST_DATE) != $first_wedn->format(JUST_DATE) && $tues_date->format('md') != '0322') { $ts = strtotime('+1 month', $ts); var_dump($tues_date->format('md')); + var_dump($first_day); + var_dump($first_wedn); var_dump($ts); }