This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

View File

@@ -1,59 +1,61 @@
<?php
declare(strict_types=1);
namespace Cron;
use DateTimeInterface;
/**
* Month field. Allows: * , / -
* Month field. Allows: * , / -.
*/
class MonthField extends AbstractField
{
/**
* @inheritDoc
* {@inheritdoc}
*/
protected $rangeStart = 1;
/**
* @inheritDoc
* {@inheritdoc}
*/
protected $rangeEnd = 12;
/**
* @inheritDoc
* {@inheritdoc}
*/
protected $literals = [1 => 'JAN', 2 => 'FEB', 3 => 'MAR', 4 => 'APR', 5 => 'MAY', 6 => 'JUN', 7 => 'JUL',
8 => 'AUG', 9 => 'SEP', 10 => 'OCT', 11 => 'NOV', 12 => 'DEC'];
8 => 'AUG', 9 => 'SEP', 10 => 'OCT', 11 => 'NOV', 12 => 'DEC', ];
/**
* @inheritDoc
* {@inheritdoc}
*/
public function isSatisfiedBy(DateTimeInterface $date, $value)
public function isSatisfiedBy(DateTimeInterface $date, $value, bool $invert): bool
{
if ($value == '?') {
if ($value === '?') {
return true;
}
$value = $this->convertLiterals($value);
return $this->isSatisfied($date->format('m'), $value);
return $this->isSatisfied((int) $date->format('m'), $value);
}
/**
* @inheritDoc
*
* @param \DateTime|\DateTimeImmutable &$date
* @param \DateTime|\DateTimeImmutable $date
*/
public function increment(DateTimeInterface &$date, $invert = false)
public function increment(DateTimeInterface &$date, $invert = false, $parts = null): FieldInterface
{
if ($invert) {
$date = $date->modify('last day of previous month')->setTime(23, 59);
if (! $invert) {
$date = $date->modify('first day of next month');
$date = $date->setTime(0, 0);
} else {
$date = $date->modify('first day of next month')->setTime(0, 0);
$date = $date->modify('last day of previous month');
$date = $date->setTime(23, 59);
}
return $this;
}
}