mailpoet
/
vendor
/
woocommerce
/
action-scheduler
/
lib
/
cron-expression
/
CronExpression_HoursField.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_HoursField.php
31 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | class CronExpression_HoursField extends CronExpression_AbstractField |
| 4 | { |
| 5 | public function isSatisfiedBy(DateTime $date, $value) |
| 6 | { |
| 7 | return $this->isSatisfied($date->format('H'), $value); |
| 8 | } |
| 9 | public function increment(DateTime $date, $invert = false) |
| 10 | { |
| 11 | // Change timezone to UTC temporarily. This will |
| 12 | // allow us to go back or forwards and hour even |
| 13 | // if DST will be changed between the hours. |
| 14 | $timezone = $date->getTimezone(); |
| 15 | $date->setTimezone(new DateTimeZone('UTC')); |
| 16 | if ($invert) { |
| 17 | $date->modify('-1 hour'); |
| 18 | $date->setTime($date->format('H'), 59); |
| 19 | } else { |
| 20 | $date->modify('+1 hour'); |
| 21 | $date->setTime($date->format('H'), 0); |
| 22 | } |
| 23 | $date->setTimezone($timezone); |
| 24 | return $this; |
| 25 | } |
| 26 | public function validate($value) |
| 27 | { |
| 28 | return (bool) preg_match('/[\*,\/\-0-9]+/', $value); |
| 29 | } |
| 30 | } |
| 31 |