mailpoet
/
vendor
/
woocommerce
/
action-scheduler
/
lib
/
cron-expression
/
CronExpression_MonthField.php
CronExpression.php
1 year ago
CronExpression_AbstractField.php
4 years ago
CronExpression_DayOfMonthField.php
4 years ago
CronExpression_DayOfWeekField.php
4 years ago
CronExpression_FieldFactory.php
4 years ago
CronExpression_FieldInterface.php
4 years ago
CronExpression_HoursField.php
4 years ago
CronExpression_MinutesField.php
4 years ago
CronExpression_MonthField.php
4 years ago
CronExpression_YearField.php
4 years ago
index.php
3 years ago
CronExpression_MonthField.php
38 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | class CronExpression_MonthField extends CronExpression_AbstractField |
| 4 | { |
| 5 | public function isSatisfiedBy(DateTime $date, $value) |
| 6 | { |
| 7 | // Convert text month values to integers |
| 8 | $value = str_ireplace( |
| 9 | array( |
| 10 | 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', |
| 11 | 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' |
| 12 | ), |
| 13 | range(1, 12), |
| 14 | $value |
| 15 | ); |
| 16 | return $this->isSatisfied($date->format('m'), $value); |
| 17 | } |
| 18 | public function increment(DateTime $date, $invert = false) |
| 19 | { |
| 20 | if ($invert) { |
| 21 | // $date->modify('last day of previous month'); // remove for php 5.2 compat |
| 22 | $date->modify('previous month'); |
| 23 | $date->modify($date->format('Y-m-t')); |
| 24 | $date->setTime(23, 59); |
| 25 | } else { |
| 26 | //$date->modify('first day of next month'); // remove for php 5.2 compat |
| 27 | $date->modify('next month'); |
| 28 | $date->modify($date->format('Y-m-01')); |
| 29 | $date->setTime(0, 0); |
| 30 | } |
| 31 | return $this; |
| 32 | } |
| 33 | public function validate($value) |
| 34 | { |
| 35 | return (bool) preg_match('/[\*,\/\-0-9A-Z]+/', $value); |
| 36 | } |
| 37 | } |
| 38 |