public function testLastDayOfMonthFixLeapYear() { $transformerConfig = new ArrayTransformerConfig(); $transformerConfig->enableLastDayOfMonthFix(); $this->transformer->setConfig($transformerConfig); $rule = new Rule('FREQ=YEARLY;COUNT=5;INTERVAL=1', new \DateTime('2016-02-29')); $computed = $this->transformer->transform($rule); $this->assertCount(5, $computed); $this->assertEquals(new \DateTime('2016-02-29'), $computed[0]->getStart()); $this->assertEquals(new \DateTime('2017-02-28'), $computed[1]->getStart()); $this->assertEquals(new \DateTime('2018-02-28'), $computed[2]->getStart()); $this->assertEquals(new \DateTime('2019-02-28'), $computed[3]->getStart()); $this->assertEquals(new \DateTime('2020-02-29'), $computed[4]->getStart()); }
public function testMonthlyWithLastDayFixEnabledOnLeapYear() { $rule = new Rule('FREQ=MONTHLY;COUNT=8', new \DateTime('2016-01-31')); $transformerConfig = new ArrayTransformerConfig(); $transformerConfig->enableLastDayOfMonthFix(); $this->transformer->setConfig($transformerConfig); $computed = $this->transformer->transform($rule); $this->assertCount(8, $computed); $this->assertEquals(new \DateTime('2016-01-31'), $computed[0]->getStart()); $this->assertEquals(new \DateTime('2016-02-29'), $computed[1]->getStart()); $this->assertEquals(new \DateTime('2016-03-31'), $computed[2]->getStart()); $this->assertEquals(new \DateTime('2016-04-30'), $computed[3]->getStart()); $this->assertEquals(new \DateTime('2016-05-31'), $computed[4]->getStart()); $this->assertEquals(new \DateTime('2016-06-30'), $computed[5]->getStart()); $this->assertEquals(new \DateTime('2016-07-31'), $computed[6]->getStart()); $this->assertEquals(new \DateTime('2016-08-31'), $computed[7]->getStart()); }
public function testDtendWithLastDayOfMonthFix() { $rule = new Rule('FREQ=MONTHLY;COUNT=5;DTEND=20140201T040000', new \DateTime('2014-01-31 04:00:00')); $config = new ArrayTransformerConfig(); $config->enableLastDayOfMonthFix(); $this->transformer->setConfig($config); $computed = $this->transformer->transform($rule); $this->assertCount(5, $computed); $this->assertEquals(new \DateTime('2014-01-31 04:00:00'), $computed[0]->getStart()); $this->assertEquals(new \DateTime('2014-02-01 04:00:00'), $computed[0]->getEnd()); $this->assertEquals(new \DateTime('2014-02-28 04:00:00'), $computed[1]->getStart()); $this->assertEquals(new \DateTime('2014-03-01 04:00:00'), $computed[1]->getEnd()); $this->assertEquals(new \DateTime('2014-03-31 04:00:00'), $computed[2]->getStart()); $this->assertEquals(new \DateTime('2014-04-01 04:00:00'), $computed[2]->getEnd()); $this->assertEquals(new \DateTime('2014-04-30 04:00:00'), $computed[3]->getStart()); $this->assertEquals(new \DateTime('2014-05-01 04:00:00'), $computed[3]->getEnd()); $this->assertEquals(new \DateTime('2014-05-31 04:00:00'), $computed[4]->getStart()); $this->assertEquals(new \DateTime('2014-06-01 04:00:00'), $computed[4]->getEnd()); }
public function testYearlyOnLeapYearWithLastDayOfMonthFix() { $transformerConfig = new ArrayTransformerConfig(); $transformerConfig->enableLastDayOfMonthFix(); $this->transformer->setConfig($transformerConfig); $rule = new Rule('FREQ=YEARLY;COUNT=5;BYHOUR=14,15', new \DateTime('2016-02-29 12:00:00')); $computed = $this->transformer->transform($rule); $this->assertCount(5, $computed); $this->assertEquals(new \DateTime('2016-02-29 14:00:00'), $computed[0]->getStart()); $this->assertEquals(new \DateTime('2016-02-29 15:00:00'), $computed[1]->getStart()); $this->assertEquals(new \DateTime('2017-02-28 14:00:00'), $computed[2]->getStart()); $this->assertEquals(new \DateTime('2017-02-28 15:00:00'), $computed[3]->getStart()); $this->assertEquals(new \DateTime('2018-02-28 14:00:00'), $computed[4]->getStart()); }
public function testLastDayOfMonthFixOn29thDayIn30DayMonth() { $transformerConfig = new ArrayTransformerConfig(); $transformerConfig->enableLastDayOfMonthFix(); $this->transformer->setConfig($transformerConfig); $rule = new Rule('FREQ=MONTHLY;COUNT=4;INTERVAL=1', new \DateTime('2014-08-29')); $computed = $this->transformer->transform($rule); $this->assertCount(4, $computed); $this->assertEquals(new \DateTime('2014-08-29'), $computed[0]->getStart()); $this->assertEquals(new \DateTime('2014-09-29'), $computed[1]->getStart()); $this->assertEquals(new \DateTime('2014-10-29'), $computed[2]->getStart()); $this->assertEquals(new \DateTime('2014-11-29'), $computed[3]->getStart()); }