OphTrOperationbooking_Operation_Sequence::getWeekOccurrences PHP Méthode

getWeekOccurrences() public méthode

public getWeekOccurrences ( $weekday, $weekSelection, $startTimestamp, $endTimestamp, $startDate, $endDate )
    public function getWeekOccurrences($weekday, $weekSelection, $startTimestamp, $endTimestamp, $startDate, $endDate)
    {
        $dates = array();
        $month = strtotime(date('Y-m-01', $startTimestamp));
        $weekday_options = $this->getWeekdayOptions();
        $weekday_string = $weekday_options[$weekday];
        while ($month <= $endTimestamp) {
            $day = strtotime("first {$weekday_string} of", $month);
            for ($i = self::SELECT_1STWEEK; $i <= self::SELECT_5THWEEK; $i *= 2) {
                // Only add date if it is between start and end dates, and is a selected week. Also check we haven't rolled over into the next month (4 week months)
                if ($day >= $startTimestamp && $day <= $endTimestamp && $day <= strtotime('last day of', $month) && $weekSelection & $i) {
                    $dates[] = date('Y-m-d', $day);
                }
                $day = strtotime('+1 week', $day);
            }
            $month = strtotime('+1 month', $month);
        }
        return $dates;
    }