diff --git a/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php b/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php --- a/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php +++ b/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php @@ -850,7 +850,7 @@ $months_in_year = 12; if ($this->cursorMonth > $months_in_year) { - $this->cursorMonth - $months_in_year; + $this->cursorMonth -= $months_in_year; return array(); } diff --git a/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php b/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php --- a/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php +++ b/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php @@ -419,6 +419,20 @@ '19970902T063010Z', ); + // TODO: This does not pass yet because BYSETPOS is not implemented + // properly for YEARLY rules. + + // $tests[] = array( + // 'BYMONTHDAY' => array(15), + // 'BYHOUR' => array(6, 18), + // 'BYSETPOS' => array(3, -3), + // ); + // $expect[] = array( + // '19971115T180000Z', + // '19980215T060000Z', + // '19981115T180000Z', + // ); + $this->assertRules( array( 'FREQ' => 'YEARLY', @@ -429,6 +443,45 @@ $expect); } + public function testMonthlyRecurrenceRules() { + $tests = array(); + $expect = array(); + + $tests[] = array(); + $expect[] = array( + '19970902', + '19971002', + '19971102', + ); + + $tests[] = array( + 'INTERVAL' => 2, + ); + $expect[] = array( + '19970902', + '19971102', + '19980102', + ); + + $tests[] = array( + 'INTERVAL' => 18, + ); + $expect[] = array( + '19970902', + '19990302', + '20000902', + ); + + $this->assertRules( + array( + 'FREQ' => 'MONTHLY', + 'COUNT' => 3, + 'DTSTART' => '19970902', + ), + $tests, + $expect); + } + private function assertRules(array $defaults, array $tests, array $expect) { foreach ($tests as $key => $test) { $options = $test + $defaults;