/**
  * Gets timestamp from date
  * @param $date
  * @return int
  */
 private function getDateTimestamp($date)
 {
     return SchedulerHelperDate::getDateTimestamp($date, $this->config["server_date"]);
 }
 /**
  * Get recurring dates by interval or $intervalStartDateStamp and $countDates.
  * @param $intervalStartDateStamp
  * @param $intervalEndDateStamp
  * @param null $countDates
  * @return array|bool
  */
 public function getRecurringDates($intervalStartDateStamp, $intervalEndDateStamp, $countDates = NULL)
 {
     if (!($this->getRecurringTypeStepValue() && $this->getRecurringTypeValue())) {
         return false;
     }
     //Correct interval by recurring interval.
     $correctedInterval = $this->_getCorrectedRecurringInterval($intervalStartDateStamp, $intervalEndDateStamp);
     $intervalStartDateStamp = $correctedInterval["start_date_stamp"];
     $intervalEndDateStamp = $correctedInterval["end_date_stamp"];
     $currentRecurringStartDateStamp = $intervalStartDateStamp;
     $recurringDates = array();
     //Generate dates wile next recurring date belongs to interval.
     $countRecurringCycles = 0;
     while (!is_null($countDates) && $countRecurringCycles <= $countDates || $intervalStartDateStamp <= $currentRecurringStartDateStamp && $currentRecurringStartDateStamp <= $intervalEndDateStamp) {
         $countRecurringCycles++;
         $recurringDays = $this->_getRecurringDays($currentRecurringStartDateStamp);
         $recurringDates = array_merge($recurringDates, $recurringDays);
         $recurringTypeStep = $this->getRecurringTypeStepValue();
         switch ($this->getRecurringTypeValue()) {
             case self::REC_TYPE_DAY:
                 $currentRecurringStartDateStamp = SchedulerHelperDate::addDays($currentRecurringStartDateStamp, $recurringTypeStep);
                 break;
             case self::REC_TYPE_WEEK:
                 $currentRecurringStartDateStamp = SchedulerHelperDate::addWeeks($currentRecurringStartDateStamp, $recurringTypeStep);
                 break;
             case self::REC_TYPE_MONTH:
                 $currentRecurringStartDateStamp = SchedulerHelperDate::addMonths($currentRecurringStartDateStamp, $recurringTypeStep);
                 break;
             case self::REC_TYPE_YEAR:
                 $currentRecurringStartDateStamp = SchedulerHelperDate::addYears($currentRecurringStartDateStamp, $recurringTypeStep);
                 break;
         }
     }
     return !is_null($countDates) ? array_splice($recurringDates, count($recurringDates) - $countDates) : $recurringDates;
 }
 /**
  * Get max recurring end date for recurring type.
  * @param $recurringType
  * @param $startDateStr
  * @param $eventLength
  * @return int
  */
 public function getRecurringEndDateStr($recurringType, $startDateStr, $eventLength)
 {
     $endDateStamp = RecurringType::getRecurringEndDate($recurringType, SchedulerHelperDate::getDateTimestamp($startDateStr), $eventLength);
     return date(SchedulerHelperDate::FORMAT_DEFAULT, $endDateStamp);
 }