tplaner / When

PHP Date Recursion library
https://github.com/tplaner/When
MIT License
513 stars 96 forks source link

InvalidStartDate exception #47

Closed Nekroido closed 3 years ago

Nekroido commented 8 years ago

There is no way to set a between constraint for a weekly recurrence, e.g. I want to have a 18:30 event each Monday starting from 1st of December and ending 31st of December (or any other random period).

kevtainer commented 8 years ago

You may now disable the exception behavior of InvalidStartDate, eg:

$when = new When()
$when->RFC5545_COMPLIANT = When::IGNORE;
maierwalter commented 8 years ago

I've done a change in When.php added one parameter to method "generateOccurences" public function generateOccurrences($addStartDate = true) { self::prepareDateElements();

    $count = 0;

    $dateLooper = clone $this->startDate;

    // add the start date to the list of occurrences
    if ($this->occursOn($dateLooper))
    {
        $this->addOccurrence($this->generateTimeOccurrences($dateLooper));
    }
    else
    {
       if($addStartDate==true){
            throw new InvalidStartDate();
        }
    }

///