From 0feb4e23d55459644bd0016b00ed3cd85c95ba53 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 28 Sep 2011 13:35:29 +0800 Subject: [PATCH] Fix bug handling COUNT= with BYDAY=multiple and FREQ=WEEKLY --- inc/RRule-v2.php | 5 ++++- testing/test-RRULE-v2.php | 2 ++ .../tests/regression-suite/0831-Spec-RRULE-1.result | 10 +++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/inc/RRule-v2.php b/inc/RRule-v2.php index 77b55209..eb0959ab 100644 --- a/inc/RRule-v2.php +++ b/inc/RRule-v2.php @@ -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; + } } } } diff --git a/testing/test-RRULE-v2.php b/testing/test-RRULE-v2.php index c9c68d57..b0a6e1b8 100755 --- a/testing/test-RRULE-v2.php +++ b/testing/test-RRULE-v2.php @@ -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 ) { diff --git a/testing/tests/regression-suite/0831-Spec-RRULE-1.result b/testing/tests/regression-suite/0831-Spec-RRULE-1.result index 7e05bade..a046826e 100644 --- a/testing/tests/regression-suite/0831-Spec-RRULE-1.result +++ b/testing/tests/regression-suite/0831-Spec-RRULE-1.result @@ -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 (-: