Skip to content

Instantly share code, notes, and snippets.

@santarinto
Created December 6, 2020 13:55
Show Gist options
  • Save santarinto/0eb1e7b4a458948f5201055651cf5f50 to your computer and use it in GitHub Desktop.
Save santarinto/0eb1e7b4a458948f5201055651cf5f50 to your computer and use it in GitHub Desktop.
average ideal ferrary
<?php
$date = new DateTime('0001-01-01');
$now = new DateTime('2022-01-01');
$count = 0;
while ($date < $now) {
$isSuitable = false;
if ((int)$date->format('m') === 2) {
$d1 = clone $date;
$d1->add(new DateInterval('P28D'));
if ((int)$d1->format('m') > 2) {
if ($date->format('D') === 'Mon') {
$isSuitable = true;
}
}
}
if ($isSuitable) {
echo ++$count . ': ' . $date->format('d-m-Y') . PHP_EOL;
}
$date->add(new DateInterval('P1M'));
}
echo 'Total: ' . $count . ' cases, average: ' . (2021 / $count) . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment