summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexKlimenkov <shurick.klimenkov@gmail.com>2016-07-06 16:30:48 +0300
committerGitHub <noreply@github.com>2016-07-06 16:30:48 +0300
commitc5dadfc3de449081ce6b0f10ae2ef2795fd575e1 (patch)
tree35327e64de5eaa94f446eb21b05fa769f52cc0c1
parentf5b8032b032ab696b3e558ced82fd36990573d75 (diff)
parent311ab45fc117448c5d6181b0e106908898b2242a (diff)
downloadscheduler-helper-php-c5dadfc3de449081ce6b0f10ae2ef2795fd575e1.zip
scheduler-helper-php-c5dadfc3de449081ce6b0f10ae2ef2795fd575e1.tar.gz
scheduler-helper-php-c5dadfc3de449081ce6b0f10ae2ef2795fd575e1.tar.bz2
Merge pull request #27 from mperednya/master
Fix month recurrings with specific day on specific week.
-rw-r--r--RecurringType.php4
-rw-r--r--tests/Data_getData/MonthRecurrings3/source.json12
-rw-r--r--tests/Data_getData/MonthRecurrings3/target.json3
3 files changed, 19 insertions, 0 deletions
diff --git a/RecurringType.php b/RecurringType.php
index eab57ee..bb82a3e 100644
--- a/RecurringType.php
+++ b/RecurringType.php
@@ -285,6 +285,10 @@ class RecurringType {
$date->setDate($recStartDetails["year"], $recStartDetails["month"] + $delta * $step, $recStartDetails["day"]);
$recurringInterval["start_date_stamp"] = $date->getTimestamp();
+ $weekNumber = $this->getWeekNumberValue();
+ if ($weekNumber)
+ $recurringInterval["start_date_stamp"] =
+ $this->_getDayOnWeek($recurringInterval["start_date_stamp"], $this->getWeekDayValue(), $weekNumber);
}
}
diff --git a/tests/Data_getData/MonthRecurrings3/source.json b/tests/Data_getData/MonthRecurrings3/source.json
new file mode 100644
index 0000000..e141831
--- /dev/null
+++ b/tests/Data_getData/MonthRecurrings3/source.json
@@ -0,0 +1,12 @@
+{
+ "settings": {
+ "start_date": "2016-07-01 08:00:00",
+ "end_date": "2016-07-20 23:59:59"
+ },
+ "data":[{ "id": "65", "start_date": "2016-06-22 08:00:00", "end_date": "9999-02-01 00:00:00", "text": "1st Monday every 1st month", "rec_type": "month_1_1_1_#no", "event_pid": "0", "event_length": "3600", "rec_pattern": "month_1_1_1_"},
+ { "id": "66", "start_date": "2016-06-02 00:00:00", "end_date": "9999-02-01 00:00:00", "text": "2nd Day every 1st month", "rec_type": "month_1___#no", "event_pid": "", "event_length": "300", "rec_pattern": "month_1___"},
+ { "id": "67", "start_date": "2016-06-04 00:00:00", "end_date": "9999-02-01 00:00:00", "text": "Every 4th day every 2nd month", "rec_type": "month_2___#no", "event_pid": "", "event_length": "300", "rec_pattern": "month_2___"},
+ { "id": "68", "start_date": "2016-06-04 00:00:00", "end_date": "9999-02-01 00:00:00", "text": "4th day every 1st month", "rec_type": "month_1___#no", "event_pid": "", "event_length": "300", "rec_pattern": "month_1___"},
+ { "id": "69", "start_date": "2016-06-16 05:00:00", "end_date": "9999-02-01 00:00:00", "text": "Every 3rd wednesday every 2nd month", "rec_type": "month_2_3_3_#no", "event_pid": "", "event_length": "21600", "rec_pattern": "month_2_3_3_"},
+ { "id": "70", "start_date": "2016-06-20 10:00:00", "end_date": "9999-02-01 00:00:00", "text": "20th day every 1st month", "rec_type": "month_1___#no", "event_pid": "", "event_length": "14400", "rec_pattern": "month_1___"}]
+} \ No newline at end of file
diff --git a/tests/Data_getData/MonthRecurrings3/target.json b/tests/Data_getData/MonthRecurrings3/target.json
new file mode 100644
index 0000000..c4de38b
--- /dev/null
+++ b/tests/Data_getData/MonthRecurrings3/target.json
@@ -0,0 +1,3 @@
+{
+ "data": [{"start_date":"2016-07-04 08:00:00","end_date":"2016-07-04 09:00:00","event_pid":"0","text":"1st Monday every 1st month","id":"65","rec_type":"month_1_1_1_#no","event_length":"3600"},{"start_date":"2016-07-02 00:00:00","end_date":"2016-07-02 00:05:00","event_pid":"0","text":"2nd Day every 1st month","id":"66","rec_type":"month_1___#no","event_length":"300"},{"start_date":"2016-07-04 00:00:00","end_date":"2016-07-04 00:05:00","event_pid":"0","text":"4th day every 1st month","id":"68","rec_type":"month_1___#no","event_length":"300"},{"start_date":"2016-07-20 10:00:00","end_date":"2016-07-20 14:00:00","event_pid":"0","text":"20th day every 1st month","id":"70","rec_type":"month_1___#no","event_length":"14400"}]
+} \ No newline at end of file