Fix bug handling COUNT= with BYDAY=multiple and FREQ=WEEKLY

This commit is contained in:
Andrew McMillan 2011-09-28 13:35:29 +08:00
parent e64f92ff86
commit 0feb4e23d5
3 changed files with 15 additions and 2 deletions

View File

@ -721,7 +721,10 @@ class RepeatRule {
$position++;
$this->instances[$position] = $instance;
if ( DEBUG_RRULE ) printf( "Added date %s into position %d in current set\n", $instance->format('c'), $position );
if ( isset($this->count) && ($position + 1) >= $this->count ) $this->finished = true;
if ( isset($this->count) && ($position + 1) >= $this->count ) {
$this->finished = true;
return;
}
}
}
}

View File

@ -89,6 +89,8 @@ $tests = array(
, new RRuleTest( "Time zone 2", "19700927T020000", "FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=9" )
, new RRuleTest( "Time zone 3", "19810329T030000", "FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU" )
, new RRuleTest( "Time zone 4", "20000404T010000", "FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;COUNT=15" )
, new RRuleTest( "Six Working Days", "20110905", "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR;COUNT=6" )
, new RRuleTest( "Six Working Days", "20110905", "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=6" )
);
foreach( $tests AS $k => $test ) {

View File

@ -2,7 +2,7 @@ HTTP/1.1 200 OK
Date: Dow, 01 Jan 2000 00:00:00 GMT
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
DAV: extended-mkcol, calendar-proxy, bind, addressbook, calendar-auto-schedule
Content-Length: 7224
Content-Length: 7623
Content-Type: text/plain
#!/usr/bin/php
@ -131,3 +131,11 @@ PHP & SQL results are identical (-:
20000404T010000 - FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;COUNT=15
Time zone 4
PHP & SQL results are identical (-:
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
20110905 - FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR;COUNT=6
Six Working Days
PHP & SQL results are identical (-:
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
20110905 - FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=6
Six Working Days
PHP & SQL results are identical (-: