34 $tday = str_pad($targetDay, 2,
'0', STR_PAD_LEFT);
35 $target = DateTime::createFromFormat(
'Y-m-d',
"$currentYear-$currentMonth-$tday");
36 $currentWeekday = (int) $target->format(
'N');
38 if ($currentWeekday < 6) {
42 $lastDayOfMonth = $target->format(
't');
44 foreach (array(-1, 1, -2, 2) as
$i) {
45 $adjusted = $targetDay +
$i;
46 if ($adjusted > 0 && $adjusted <= $lastDayOfMonth) {
47 $target->setDate($currentYear, $currentMonth, $adjusted);
48 if ($target->format(
'N') < 6 && $target->format(
'm') == $currentMonth) {
65 $fieldValue = $date->format(
'd');
69 return $fieldValue == $date->format(
't');
73 if (strpos($value,
'W')) {
75 $targetDay = substr($value, 0, strpos($value,
'W'));
77 return $date->format(
'j') ==
self::getNearestWeekday($date->format(
'Y'), $date->format(
'm'), $targetDay)->format(
'j');
80 return $this->
isSatisfied($date->format(
'd'), $value);
86 public function increment(DateTime $date, $invert =
false)
89 $date->sub(
new DateInterval(
'P1D'));
90 $date->setTime(23, 59, 0);
92 $date->add(
new DateInterval(
'P1D'));
93 $date->setTime(0, 0, 0);
104 return (
bool) preg_match(
'/[\*,\/\-\?LW0-9A-Za-z]+/', $value);