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

Recurrence rules don't allow multiple values for BYMONTH, BYHOUR, BYMINUTE, BYSECOND #130

Open
lukaswhite opened this issue Mar 14, 2019 · 0 comments

Comments

@lukaswhite
Copy link

Recurrence rules are allowed multiple values for BYMONTH, BYHOUR, BYMINUTE and BYSECOND, for example:

DTSTART;TZID=US-Eastern:19970902T090000
  RRULE:FREQ=DAILY;BYHOUR=9,10,11,12,13,14,15,16;BYMINUTE=0,20,40

(source)

However, the corresponding methods (setByMonth(), setByHour(), setByMinute(), setBySecond()) don't allow multiple values; they throw an InvalidArgumentException.

For example:

public function setByMonth($month)
{
    if (!is_integer($month) || $month < 0 || $month > 12) {
        throw new InvalidArgumentException('Invalid value for BYMONTH');
    }

    $this->byMonth = $month;

    return $this;
}

Because it's insisting on a single, integer value, you can't do this:

$rule->setByMonth( '1,3,5' );

By contrast, setByDay() looks like this:

public function setByDay(string $day)
{
    $this->byDay = $day;

    return $this;
}

I'd be happy to submit a PR, it's just a question of whether it's worth validating string values, for example throwing an exception if you did something like this:

$rule->setByMonth( '1,3,13' );

...or...

$rule->setByMonth( 'JAN,MAR,MAY' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant