Example #1
0
 /**
  * Create a new range from 2 dates.
  *
  * @param DateTime $start The start date of the range
  * @param DateTime $end The end date of the range
  */
 public function __construct(DateTime $start, DateTime $end)
 {
     $this->start = $start;
     $this->end = $end;
     if ($this->end->timestamp() < $this->start->timestamp()) {
         throw new \InvalidArgumentException("Invalid range, the start date must be before the end date");
     }
 }
Example #2
0
 /**
  * Create a new instance from a date object.
  *
  * @param DateTime $date A date within the season
  */
 public function __construct(DateTime $date)
 {
     $this->unix = $date->timestamp();
     $start = Date::mkdate($date->numeric("Y"), $date->numeric("n"), 1);
     $end = Date::mkdate($date->numeric("Y"), $date->numeric("n"), $date->numeric("t"));
     parent::__construct($start, $end);
 }
Example #3
0
 /**
  * @param DateTime $another
  * @return bool
  */
 public function equals(DateTime $another)
 {
     return $this->timestamp() === $another->timestamp();
 }