public function __construct($month_day, $month, $year, HijriAlgorithmBase $algorithm) { $this->algorithm = $algorithm; if (!$this->algorithm->isValidDate($month_day, $month, $year, $errors)) { throw new InvalidDateException($errors); } parent::__construct($month_day, $month, $year); }
public function __construct($month_day, $month, $year) { $errors = []; $algorithm = new GregorianAlgorithm(); if (!$algorithm->isValidDate($month_day, $month, $year, $errors)) { throw new InvalidDateException($errors); } // Create a DateTime object directly. $this->datetime = \DateTimeImmutable::createFromFormat('n/j/Y', sprintf('%d/%d/%d', $month, $month_day, $year)); parent::__construct($month_day, $month, $year); }