Overview

Namespaces

  • Cron
  • None

Classes

  • AbstractField
  • CronExpression
  • DayOfMonthField
  • DayOfWeekField
  • FieldFactory
  • HoursField
  • MinutesField
  • MonthField
  • YearField

Interfaces

  • FieldInterface
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace Cron;
 4: 
 5: /**
 6:  * Hours field.  Allows: * , / -
 7:  */
 8: class HoursField extends AbstractField
 9: {
10:     public function isSatisfiedBy(\DateTime $date, $value)
11:     {
12:         return $this->isSatisfied($date->format('H'), $value);
13:     }
14: 
15:     public function increment(\DateTime $date, $invert = false)
16:     {
17:         // Change timezone to UTC temporarily. This will
18:         // allow us to go back or forwards and hour even
19:         // if DST will be changed between the hours.
20:         $timezone = $date->getTimezone();
21:         $date->setTimezone(new \DateTimeZone('UTC'));
22:         if ($invert) {
23:             $date->modify('-1 hour');
24:             $date->setTime($date->format('H'), 59);
25:         } else {
26:             $date->modify('+1 hour');
27:             $date->setTime($date->format('H'), 0);
28:         }
29:         $date->setTimezone($timezone);
30: 
31:         return $this;
32:     }
33: 
34:     public function validate($value)
35:     {
36:         return (bool) preg_match('/[\*,\/\-0-9]+/', $value);
37:     }
38: }
39: 
API documentation generated by ApiGen 2.8.0