summaryrefslogtreecommitdiffstats
path: root/RecurringType.php
diff options
context:
space:
mode:
authorsten <stenmarsh938@gmail.com>2016-03-11 21:47:51 +0300
committersten <stenmarsh938@gmail.com>2016-03-11 21:47:51 +0300
commitddf59163cf912bfea6f7d307f40413d79837db9e (patch)
treec156d08462396a88a64ed00cb05f5a7c0299cb68 /RecurringType.php
parentc75c2b1b48bc64835f6de0159ad9cc5d027771bd (diff)
parent30987b06815c57f7630d368443ee4f92c94e2852 (diff)
downloadscheduler-helper-php-ddf59163cf912bfea6f7d307f40413d79837db9e.zip
scheduler-helper-php-ddf59163cf912bfea6f7d307f40413d79837db9e.tar.gz
scheduler-helper-php-ddf59163cf912bfea6f7d307f40413d79837db9e.tar.bz2
Merge remote-tracking branch 'upstream/weekly_and_endless_series_fix'
Diffstat (limited to 'RecurringType.php')
-rw-r--r--RecurringType.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/RecurringType.php b/RecurringType.php
index d26fb16..5537e27 100644
--- a/RecurringType.php
+++ b/RecurringType.php
@@ -158,7 +158,7 @@ class RecurringType {
static private function _parseRecurringDataString($dataStr)
{
$formatPartsReg = "/(_|#)/";
- $formatDaysListPartReg = "/,/";
+ $formatDaysListDelimiter = ",";
$parsedData = array();
$parts = preg_split($formatPartsReg, $dataStr);
@@ -175,8 +175,14 @@ class RecurringType {
$parsedData[self::FLD_REPEAT] = $parts[5];
}
- $parsedData[self::FLD_WEEK_DAYS_LIST] = ($parsedData[self::FLD_WEEK_DAYS_LIST]) ?
- preg_split($formatDaysListPartReg, $parsedData[self::FLD_WEEK_DAYS_LIST]) : array();
+ $days = $parsedData[self::FLD_WEEK_DAYS_LIST];
+
+ // $days is a comma separated week days string ("0,1,2"). Need an extra check for `every Sunday` series - "0" - which string is considered as falsy/empty in php
+ if(!empty($days) || $days === "0"){
+ $parsedData[self::FLD_WEEK_DAYS_LIST] = explode($formatDaysListDelimiter, $days);
+ }else{
+ $parsedData[self::FLD_WEEK_DAYS_LIST] = array();
+ }
return $parsedData;
}