mirror of
https://github.com/rlanvin/php-rrule.git
synced 2025-02-20 09:54:16 +01:00
Fix a bug in BYDAY
Fixed a bug when combining values with an integer modifier and regular values in `BYDAY` (example `1MO,FR`)
This commit is contained in:
parent
06cd709805
commit
7c041bfb42
@ -2,7 +2,13 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
n/a
|
||||
### Added
|
||||
|
||||
- Italian translation (it) [#14](https://github.com/rlanvin/php-rrule/pull/14)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed a bug when combining values with an integer modifier and regular values in `BYDAY` (example `1MO,FR`)
|
||||
|
||||
## [1.3.0] - 2016-07-08
|
||||
|
||||
|
@ -888,10 +888,6 @@ class RRule implements RRuleInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->byweekday && ! in_array($weekday, $this->byweekday) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->bymonthday || $this->bymonthday_negative ) {
|
||||
$monthday_negative = -1 * ($month_len - $day + 1);
|
||||
|
||||
@ -909,10 +905,11 @@ class RRule implements RRuleInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->byweekday_nth ) {
|
||||
if ( $this->byweekday || $this->byweekday_nth ) {
|
||||
// we need to summon some magic here
|
||||
$this->buildNthWeekdayMask($year, $month, $day, $masks);
|
||||
if ( ! isset($masks['yearday_is_nth_weekday'][$yearday]) ) {
|
||||
|
||||
if ( ! in_array($weekday, $this->byweekday) && ! isset($masks['yearday_is_nth_weekday'][$yearday]) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1703,6 +1700,7 @@ class RRule implements RRuleInterface
|
||||
|
||||
$filtered_set = array();
|
||||
|
||||
// filter out the days based on the BY*** rules
|
||||
foreach ( $dayset as $yearday ) {
|
||||
if ( $this->bymonth && ! in_array($masks['yearday_to_month'][$yearday], $this->bymonth) ) {
|
||||
continue;
|
||||
@ -1731,11 +1729,9 @@ class RRule implements RRuleInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->byweekday && ! in_array($masks['yearday_to_weekday'][$yearday], $this->byweekday) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->byweekday_nth && ! isset($masks['yearday_is_nth_weekday'][$yearday]) ) {
|
||||
if ( ( $this->byweekday || $this->byweekday_nth )
|
||||
&& ! in_array($masks['yearday_to_weekday'][$yearday], $this->byweekday)
|
||||
&& ! isset($masks['yearday_is_nth_weekday'][$yearday]) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -229,6 +229,13 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1997-10-31'),
|
||||
date_create('1997-11-28'))),
|
||||
|
||||
// first working day of the month, or previous Friday
|
||||
// see http://stackoverflow.com/questions/38170676/recurring-calendar-event-on-first-of-the-month/38314515
|
||||
array(array('BYDAY'=>'1MO,1TU,1WE,1TH,1FR,-1FR','BYMONTHDAY'=>'1,-1,-2'),
|
||||
array(date_create('1997-10-01'),date_create('1997-10-31'),date_create('1997-12-01'))),
|
||||
array(array('BYDAY'=>'1MO,1TU,1WE,1TH,FR','BYMONTHDAY'=>'1,-1,-2'),
|
||||
array(date_create('1997-10-01'),date_create('1997-10-31'),date_create('1997-12-01'))),
|
||||
|
||||
array(array('BYHOUR'=> '6,18'),array(
|
||||
date_create('1997-09-02 06:00:00'),date_create('1997-09-02 18:00:00'),date_create('1997-10-02 06:00:00'))),
|
||||
array(array('BYMINUTE'=> '6,18'),array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user