protected function prepareDateElements() { // if the interval isn't set, set it. if (!isset($this->interval)) { $this->interval = 1; } // must have a frequency if (!isset($this->freq) && Valid::byFreqValid($this->freq, $this->byweeknos, $this->byyeardays, $this->bymonthdays)) { throw new FrequencyRequired(); } if (!isset($this->count)) { $this->count = 200; } // "Similarly, if the BYMINUTE, BYHOUR, BYDAY, // BYMONTHDAY, or BYMONTH rule part were missing, the appropriate // minute, hour, day, or month would have been retrieved from the // "DTSTART" property." // if there is no startDate, make it now if (!$this->startDate) { $this->startDate = new \DateTime(); } // the calendar repeats itself every 400 years, so if a date // doesn't exist for 400 years, I don't think it will ever // occur if (!isset($this->until)) { $this->until = new \DateTime(); $this->until->add(new \DateInterval('P400Y')); } if (!isset($this->byminutes)) { $this->byminutes = array((int) $this->startDate->format('i')); } if (!isset($this->byhours)) { $this->byhours = array((int) $this->startDate->format('G')); } if (!isset($this->byseconds)) { $this->byseconds = array((int) $this->startDate->format('s')); } if (!isset($this->wkst)) { $this->wkst = "mo"; } /*if (!isset($this->bydays)) { $dayOfWeek = $this->startDate->format('l'); $dayOfWeekAbr = strtolower(substr($dayOfWeek, 0, 2)); $this->bydays = array($dayOfWeekAbr); }*/ if ($this->freq === "monthly") { if (!isset($this->bymonthdays) && !isset($this->bydays)) { $this->bymonthdays = array((int) $this->startDate->format('j')); } } if ($this->freq === "weekly") { if (!isset($this->bymonthdays) && !isset($this->bydays)) { $dayOfWeek = $this->startDate->format('l'); $dayOfWeekAbr = strtolower(substr($dayOfWeek, 0, 2)); $this->bydays = array("0" . $dayOfWeekAbr); } } if ($this->freq === "yearly") { if (!isset($this->bydays) && !isset($this->bymonths) && !isset($this->bymonthdays) && !isset($this->byyeardays) && !isset($this->byweeknos) && !isset($this->bysetpos)) { $this->bymonth($this->startDate->format('n')); } } }