RRule\RRule::getDaySet PHP Method

getDaySet() protected method

Return an array of days of the year (numbered from 0 to 365) of the current timeframe (year, month, week, day) containing the current date
protected getDaySet ( integer $year, integer $month, integer $day, array $masks ) : array
$year integer
$month integer
$day integer
$masks array
return array
    protected function getDaySet($year, $month, $day, array $masks)
    {
        switch ($this->freq) {
            case self::YEARLY:
                return range(0, $masks['year_len'] - 1);
            case self::MONTHLY:
                $start = $masks['last_day_of_month'][$month - 1];
                $stop = $masks['last_day_of_month'][$month];
                return range($start, $stop - 1);
            case self::WEEKLY:
                // on first iteration, the first week will not be complete
                // we don't backtrack to the first day of the week, to avoid
                // crossing year boundary in reverse (i.e. if the week started
                // during the previous year), because that would generate
                // negative indexes (which would not work with the masks)
                $set = array();
                $i = (int) date_create($year . '-' . $month . '-' . $day . ' 00:00:00')->format('z');
                $start = $i;
                for ($j = 0; $j < 7; $j++) {
                    $set[] = $i;
                    $i += 1;
                    if ($masks['yearday_to_weekday'][$i] == $this->wkst) {
                        break;
                    }
                }
                return $set;
            case self::DAILY:
            case self::HOURLY:
            case self::MINUTELY:
            case self::SECONDLY:
                $i = (int) date_create($year . '-' . $month . '-' . $day . ' 00:00:00')->format('z');
                return array($i);
        }
    }