Exemple #1
0
 /**
  * Returns new DateTime object
  *
  * @param mixed time[optional]
  * @return \DateTime
  */
 public function __invoke($time = null)
 {
     if (null === $time) {
         $time = 'now';
     }
     return DateTimeUtils::normalize($time);
 }
Exemple #2
0
 /**
  * @param array|string $options
  * @return bool
  */
 private function isValid($options)
 {
     if (is_string($options)) {
         return true;
     }
     if (isset($options['enabled']) && !$options['enabled']) {
         return false;
     }
     if (!empty($options['since']) && DateTimeUtils::normalize($options['since']) > new DateTime('now') || !empty($options['to']) && DateTimeUtils::normalize($options['to']) < new DateTime('now')) {
         return false;
     }
     return true;
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function setTo($date)
 {
     $this->to = DateTimeUtils::normalize($date);
     return $this;
 }