mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-21 01:54:23 +00:00
[RRule] Fix bug in GetNext for a daily event with a BYDAY rule.
This commit is contained in:
parent
347045c4c4
commit
f7c7620dea
@ -252,7 +252,7 @@ class iCalDate {
|
|||||||
* Add some integer number of days to a date
|
* Add some integer number of days to a date
|
||||||
*/
|
*/
|
||||||
function AddDays( $dd ) {
|
function AddDays( $dd ) {
|
||||||
dbg_error_log( "RRule", " Adding %d days to %s", $dd, $this->_text );
|
$at_start = $this->_text;
|
||||||
$this->_dd += $dd;
|
$this->_dd += $dd;
|
||||||
while ( 1 > $this->_dd ) {
|
while ( 1 > $this->_dd ) {
|
||||||
$this->_mo--;
|
$this->_mo--;
|
||||||
@ -272,7 +272,7 @@ class iCalDate {
|
|||||||
}
|
}
|
||||||
$this->_EpochFromParts();
|
$this->_EpochFromParts();
|
||||||
$this->_TextFromEpoch();
|
$this->_TextFromEpoch();
|
||||||
dbg_error_log( "RRule", " Added %d days and got %s", $dd, $this->_text );
|
dbg_error_log( "RRule", " Added %d days to %s and got %s", $dd, $at_start, $this->_text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -436,20 +436,23 @@ class iCalDate {
|
|||||||
/**
|
/**
|
||||||
* Applies any BYDAY to the week to return a set of days
|
* Applies any BYDAY to the week to return a set of days
|
||||||
* @param string $byday The BYDAY rule
|
* @param string $byday The BYDAY rule
|
||||||
|
* @param string $increasing When we are moving by months, we want any day of the week, but when by day we only want to increase. Default false.
|
||||||
* @return array An array of the day numbers for the week which meet the rule.
|
* @return array An array of the day numbers for the week which meet the rule.
|
||||||
*/
|
*/
|
||||||
function GetWeekByDay($byday) {
|
function GetWeekByDay($byday, $increasing = false) {
|
||||||
global $ical_weekdays;
|
global $ical_weekdays;
|
||||||
dbg_error_log( "RRule", " Applying BYDAY %s to week", $byday );
|
dbg_error_log( "RRule", " Applying BYDAY %s to week", $byday );
|
||||||
$days = split(',',$byday);
|
$days = split(',',$byday);
|
||||||
$dow = date('w',$this->_epoch);
|
$dow = date('w',$this->_epoch);
|
||||||
|
$set = array();
|
||||||
foreach( $days AS $k => $v ) {
|
foreach( $days AS $k => $v ) {
|
||||||
$daynum = $ical_weekdays[$v];
|
$daynum = $ical_weekdays[$v];
|
||||||
$dd = $this->_dd - $dow + $daynum;
|
$dd = $this->_dd - $dow + $daynum;
|
||||||
if ( $daynum < $this->_wkst ) $dd += 7;
|
if ( $daynum < $this->_wkst ) $dd += 7;
|
||||||
$set[$dd] = $dd;
|
if ( $dd > $this->_dd || !$increasing ) $set[$dd] = $dd;
|
||||||
}
|
}
|
||||||
asort( $set, SORT_NUMERIC );
|
asort( $set, SORT_NUMERIC );
|
||||||
|
|
||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,7 +904,7 @@ class RRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($this->_part['BYDAY']) ) {
|
if ( isset($this->_part['BYDAY']) ) {
|
||||||
$days = $next->GetWeekByDay($this->_part['BYDAY']);
|
$days = $next->GetWeekByDay($this->_part['BYDAY'], true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$days[$next->_dd] = $next->_dd;
|
$days[$next->_dd] = $next->_dd;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user