summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsten <stenmarsh938@gmail.com>2016-03-21 17:32:16 +0300
committersten <stenmarsh938@gmail.com>2016-03-21 17:32:16 +0300
commit5dfac44bc3b304943e40dc46531d05015829d4ae (patch)
tree6cb642ca24b11c1ed69fba0520ccabbb23a8adfa
parent4e6ec96d0e50f26b54c58abea48ebca6ee7ffb47 (diff)
parent13053f9a9f7a29ad554ba2587f708c6fa65dba53 (diff)
downloadscheduler-helper-php-5dfac44bc3b304943e40dc46531d05015829d4ae.zip
scheduler-helper-php-5dfac44bc3b304943e40dc46531d05015829d4ae.tar.gz
scheduler-helper-php-5dfac44bc3b304943e40dc46531d05015829d4ae.tar.bz2
Merge branch 'master' into helperTests
-rw-r--r--RecurringType.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/RecurringType.php b/RecurringType.php
index 34bf8eb..138d2d6 100644
--- a/RecurringType.php
+++ b/RecurringType.php
@@ -311,9 +311,11 @@ class RecurringType {
/**
* Get recurring days for date.
* @param $dateStamp
+ * @param $start
+ * $param $end
* @return array
*/
- private function _getRecurringDays($dateStamp)
+ private function _getRecurringDays($dateStamp, $start = NULL, $end = NULL)
{
$recurringDays = array();
@@ -323,18 +325,24 @@ class RecurringType {
$daysCount = count($recurringWeekDays);
for($i = 0; $i < $daysCount; $i++) {
$dayStep = $this->_getRecurringDayStep($dateStamp, $recurringWeekDays[$i]);
- array_push($recurringDays, SchedulerHelperDate::addDays($dateStamp, $dayStep));
+ $stamp = SchedulerHelperDate::addDays($dateStamp, $dayStep);
+ if((!$start || $stamp >= $start) && (!$end|| $stamp < $end))
+ array_push($recurringDays, $stamp);
}
}
//Else if recurring type has day of week and step for it, then get this day.
elseif($this->getWeekDayValue() && $this->getWeekNumberValue()) {
$dayStep = $this->_getRecurringDayStep($dateStamp, $this->getWeekDayValue());
$dayStep += (SchedulerHelperDate::DAYS_IN_WEEK * ($this->getWeekNumberValue() - 1));
- array_push($recurringDays, SchedulerHelperDate::addDays($dateStamp, $dayStep));
+ $stamp = SchedulerHelperDate::addDays($dateStamp, $dayStep);
+ if((!$start || $stamp >= $start) && (!$end|| $stamp < $end))
+ array_push($recurringDays, $stamp);
}
//Else return recurring date without change.
- else
- array_push($recurringDays, $dateStamp);
+ else {
+ if((!$start || $dateStamp >= $start) && (!$end|| $dateStamp < $end))
+ array_push($recurringDays, $dateStamp);
+ }
return $recurringDays;
}
@@ -360,6 +368,8 @@ class RecurringType {
$intervalEndDateStamp = $correctedInterval["end_date_stamp"];
$currentRecurringStartDateStamp = $intervalStartDateStamp;
$recurringDates = array();
+ $recurringStartDateStamp = $this->_recurring_start_date_stamp;
+ $recurringEndDateStamp = $this->_recurring_end_date_stamp;
//Generate dates wile next recurring date belongs to interval.
$countRecurringCycles = 0;
@@ -371,7 +381,7 @@ class RecurringType {
)
) {
$countRecurringCycles++;
- $recurringDays = $this->_getRecurringDays($currentRecurringStartDateStamp);
+ $recurringDays = $this->_getRecurringDays($currentRecurringStartDateStamp, $recurringStartDateStamp, $recurringEndDateStamp);
$recurringDates = array_merge($recurringDates, $recurringDays);
switch($recType) {