Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop setByMonthDay > 31 #103

Open
NaWer opened this issue Oct 6, 2016 · 1 comment
Open

Infinite loop setByMonthDay > 31 #103

NaWer opened this issue Oct 6, 2016 · 1 comment
Assignees
Labels

Comments

@NaWer
Copy link

NaWer commented Oct 6, 2016

Valid values are 1 to 31 or -31 to -1. It would be nice to raise error on invalid value, or min/max to avoid infinite loop.

Here is a test case :

$timezone    = 'America/New_York';
$startDate   = new \DateTime('2013-06-12 20:00:00', new \DateTimeZone($timezone));
$endDate     = new \DateTime('2013-06-14 20:00:00', new \DateTimeZone($timezone)); // Optional
$rule        = new \Recurr\Rule('FREQ=MONTHLY;COUNT=5', $startDate, $endDate, $timezone);
$rule->setByMonthDay(array(31)); // OK, june have only 30 days
$rule->setByMonthDay(array(32)); // Loop
$transformer = new \Recurr\Transformer\ArrayTransformer();

print_r($transformer->transform($rule));

[Edit] infinite loop on >= 32 and <= -33

@simshaun simshaun added the bug label Dec 1, 2016
@simshaun simshaun self-assigned this Dec 1, 2016
@friedrichroell
Copy link

same issue with:

<?php

use Recurr\Rule;
use Recurr\Transformer\ArrayTransformer;

include_once 'vendor/autoload.php';

$startDate   = new DateTime('now');
$endDate     = new DateTime('+2 month');

$rule = (new Rule)
    ->setStartDate($startDate)
    ->setInterval(14)
    ->setFreq('DAILY')
    ->setByDay(['MO', 'TU'])
    ->setUntil($endDate)
;

$transformer = new ArrayTransformer();
$transformer->transform($rule);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants