Does the processing for advancing the iterator for monthly frequency.
975182
protected function nextMonthly()
    {
        $currentDayOfMonth = $this->currentDate->format('j');
        if (!$this->byMonthDay && !$this->byDay) {
            // If the current day is higher than the 28th, rollover can
            // occur to the next month. We Must skip these invalid
            // entries.
            if ($currentDayOfMonth < 29) {
                $this->currentDate = $this->currentDate->modify('+'.$this->interval.' months');
            } else {
                $increase = 0;
                do {
                    ++$increase;
                    $tempDate = clone $this->currentDate;
                    $tempDate = $tempDate->modify('+ '.($this->interval * $increase).' months');
                } while ($tempDate->format('j') != $currentDayOfMonth);
                $this->currentDate = $tempDate;
            }

            return;
        }

        while (true) {
            $occurrences = $this->getMonthlyOccurrences();

            foreach ($occurrences as $occurrence) {
                // The first occurrence thats higher than the current
                // day of the month wins.
                if ($occurrence > $currentDayOfMonth) {
                    break 2;
                }
            }

            // If we made it all the way here, it means there were no
            // valid occurrences, and we need to advance to the next
            // month.
            //
            // This line does not currently work in hhvm. Temporary workaround
            // follows:
            // $this->currentDate->modify('first day of this month');
            $this->currentDate = new DateTimeImmutable($this->currentDate->format('Y-m-1 H:i:s'), $this->currentDate->getTimezone());
            // end of workaround
            $this->currentDate = $this->currentDate->modify('+ '.$this->interval.' months');

            // This goes to 0 because we need to start counting at the
            // beginning.
            $currentDayOfMonth = 0;

            // To prevent running this forever (better: until we hit the max date of DateTimeImmutable) we simply
            // stop at 9999-12-31. Looks like the year 10000 problem is not solved in php ....
            if ($this->currentDate->getTimestamp() > 253402300799) {
                $this->currentDate = null;

                return;
            }
        }

        $this->currentDate = $this->currentDate->setDate(
            (int) $this->currentDate->format('Y'),
            (int) $this->currentDate->format('n'),
            (int) $occurrence
        );
    }
911223
def _next_month(self):
        """"""
        self._canvas.place_forget()

        year, month = self._date.year, self._date.month
        self._date = self._date + self.timedelta(
            days=calendar.monthrange(year, month)[1] + 1)
        self._date = self.datetime(self._date.year, self._date.month, 1)
        self._build_calendar()
567222
private void increment(final Calendar cal) {
        // initialise interval..
        final int calInterval = (getInterval() >= 1) ? getInterval() : 1;
        cal.add(calIncField, calInterval);
    }
1295244
@Override
	public void addWithAutomaticPhasing (Schedulable schedulable, int frequency) {
		// Calculate the phase and add the schedulable to the list
		add(schedulable, frequency, calculatePhase(frequency));
	}
565419
function() {
        for (var p=0;p<this.pages.length;++p) {
            var cal = this.pages[p];
            cal.nextMonth();
        }
    }
638942
protected function processRecurrences()
    {
        $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array();

        $recurrenceEvents    = array();
        $allRecurrenceEvents = array();

        if (!empty($events)) {
            foreach ($events as $anEvent) {
                if (isset($anEvent['RRULE']) && $anEvent['RRULE'] !== '') {
                    // Tag as generated by a recurrence rule
                    $anEvent['RRULE_array'][2] = self::RECURRENCE_EVENT;

                    $countNb = 0;

                    $initialStart             = new \DateTime($anEvent['DTSTART_array'][1]);
                    $initialStartTimeZoneName = $initialStart->getTimezone()->getName();

                    if (isset($anEvent['DTEND'])) {
                        $initialEnd             = new \DateTime($anEvent['DTEND_array'][1]);
                        $initialEndTimeZoneName = $initialEnd->getTimezone()->getName();
                    } else {
                        $initialEndTimeZoneName = $initialStartTimeZoneName;
                    }

                    // Recurring event, parse RRULE and add appropriate duplicate events
                    $rrules = array();
                    $rruleStrings = explode(';', $anEvent['RRULE']);

                    foreach ($rruleStrings as $s) {
                        list($k, $v) = explode('=', $s);
                        $rrules[$k] = $v;
                    }

                    // Get frequency
                    $frequency = $rrules['FREQ'];
                    // Get Start timestamp
                    $startTimestamp = $initialStart->getTimestamp();

                    if (isset($anEvent['DTEND'])) {
                        $endTimestamp = $initialEnd->getTimestamp();
                    } elseif (isset($anEvent['DURATION'])) {
                        $duration = end($anEvent['DURATION_array']);
                        $endTimestamp = $this->parseDuration($anEvent['DTSTART'], $duration);
                    } else {
                        $endTimestamp = $anEvent['DTSTART_array'][2];
                    }

                    $eventTimestampOffset = $endTimestamp - $startTimestamp;
                    // Get Interval
                    $interval = (isset($rrules['INTERVAL']) && $rrules['INTERVAL'] !== '') ? $rrules['INTERVAL'] : 1;

                    $dayNumber = null;
                    $weekday   = null;

                    if (in_array($frequency, array('MONTHLY', 'YEARLY')) && isset($rrules['BYDAY']) && $rrules['BYDAY'] !== '') {
                        // Deal with BYDAY
                        $byDay     = $rrules['BYDAY'];
                        $dayNumber = intval($byDay);

                        if (empty($dayNumber)) { // Returns 0 when no number defined in BYDAY
                            if (!isset($rrules['BYSETPOS'])) {
                                $dayNumber = 1; // Set first as default
                            } elseif (is_numeric($rrules['BYSETPOS'])) {
                                $dayNumber = $rrules['BYSETPOS'];
                            }
                        }

                        $weekday = substr($byDay, -2);
                    }

                    if (is_int($this->defaultSpan)) {
                        $untilDefault = date_create('now');
                        $untilDefault->modify($this->defaultSpan . ' year');
                        $untilDefault->setTime(23, 59, 59); // End of the day
                    } else {
                        trigger_error('ICal::defaultSpan: User defined value is not an integer', E_USER_NOTICE);
                    }

                    // Compute EXDATEs
                    $exdates = $this->parseExdates($anEvent);

                    $countOrig = null;

                    if (isset($rrules['UNTIL'])) {
                        // Get Until
                        $until = strtotime($rrules['UNTIL']);
                    } elseif (isset($rrules['COUNT'])) {
                        $countOrig = (is_numeric($rrules['COUNT']) && $rrules['COUNT'] > 1) ? $rrules['COUNT'] : 0;

                        // Increment count by the number of excluded dates
                        $countOrig += sizeof($exdates);

                        // Remove one to exclude the occurrence that initialises the rule
                        $count = ($countOrig - 1);

                        if ($interval >= 2) {
                            $count += ($count > 0) ? ($count * $interval) : 0;
                        }

                        $countNb = 1;
                        $offset  = "+{$count} " . $this->frequencyConversion[$frequency];
                        $until   = strtotime($offset, $startTimestamp);

                        if (in_array($frequency, array('MONTHLY', 'YEARLY'))
                            && isset($rrules['BYDAY']) && $rrules['BYDAY'] !== ''
                        ) {
                            $dtstart = date_create($anEvent['DTSTART']);

                            if (!$dtstart) {
                                continue;
                            }

                            for ($i = 1; $i <= $count; $i++) {
                                $dtstartClone = clone $dtstart;
                                $dtstartClone->modify('next ' . $this->frequencyConversion[$frequency]);
                                $offset = "{$this->convertDayOrdinalToPositive($dayNumber, $weekday, $dtstartClone)} {$this->weekdays[$weekday]} of " . $dtstartClone->format('F Y H:i:01');
                                $dtstart->modify($offset);
                            }

                            // Jumping X months forwards doesn't mean
                            // the end date will fall on the same day defined in BYDAY
                            // Use the largest of these to ensure we are going far enough
                            // in the future to capture our final end day
                            $until = max($until, $dtstart->format(self::UNIX_FORMAT));
                        }

                        unset($offset);
                    } elseif (isset($untilDefault)) {
                        $until = $untilDefault->getTimestamp();
                    }

                    $until = intval($until);

                    // Decide how often to add events and do so
                    switch ($frequency) {
                        case 'DAILY':
                            // Simply add a new event each interval of days until UNTIL is reached
                            $offset = "+{$interval} day";
                            $recurringTimestamp = strtotime($offset, $startTimestamp);

                            while ($recurringTimestamp <= $until) {
                                $dayRecurringTimestamp = $recurringTimestamp;

                                // Adjust time zone from initial event
                                $dayRecurringOffset = 0;
                                if ($this->useTimeZoneWithRRules) {
                                    $recurringTimeZone = \DateTime::createFromFormat(self::UNIX_FORMAT, $dayRecurringTimestamp);
                                    $recurringTimeZone->setTimezone($initialStart->getTimezone());
                                    $dayRecurringOffset = $recurringTimeZone->getOffset();
                                    $dayRecurringTimestamp += $dayRecurringOffset;
                                }

                                // Add event
                                $anEvent['DTSTART'] = date(self::DATE_TIME_FORMAT, $dayRecurringTimestamp) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');
                                $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                $anEvent['DTSTART_array'][2] = $dayRecurringTimestamp;
                                $anEvent['DTEND_array']      = $anEvent['DTSTART_array'];
                                $anEvent['DTEND_array'][2]  += $eventTimestampOffset;
                                $anEvent['DTEND'] = date(
                                    self::DATE_TIME_FORMAT,
                                    $anEvent['DTEND_array'][2]
                                ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');
                                $anEvent['DTEND_array'][1] = $anEvent['DTEND'];

                                // Exclusions
                                $isExcluded = array_filter($exdates, function ($exdate) use ($anEvent, $dayRecurringOffset) {
                                    return self::isExdateMatch($exdate, $anEvent, $dayRecurringOffset);
                                });

                                if (isset($anEvent['UID'])) {
                                    $searchDate = $anEvent['DTSTART'];
                                    if (isset($anEvent['DTSTART_array'][0]['TZID'])) {
                                        $searchDate = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $anEvent['DTSTART_array'][0]['TZID']) . $searchDate;
                                    }

                                    if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                        $searchDateUtc = $this->iCalDateToUnixTimestamp($searchDate, true, true);
                                        if (in_array($searchDateUtc, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                            $isExcluded = true;
                                        }
                                    }
                                }

                                if (!$isExcluded) {
                                    $anEvent            = $this->processEventIcalDateTime($anEvent);
                                    $recurrenceEvents[] = $anEvent;
                                    $this->eventCount++;

                                    // If RRULE[COUNT] is reached then break
                                    if (isset($rrules['COUNT'])) {
                                        $countNb++;

                                        if ($countNb >= $countOrig) {
                                            break;
                                        }
                                    }
                                }

                                // Move forwards
                                $recurringTimestamp = strtotime($offset, $recurringTimestamp);
                            }

                            $recurrenceEvents    = $this->trimToRecurrenceCount($rrules, $recurrenceEvents);
                            $allRecurrenceEvents = array_merge($allRecurrenceEvents, $recurrenceEvents);
                            $recurrenceEvents    = array(); // Reset
                            break;

                        case 'WEEKLY':
                            // Create offset
                            $offset = "+{$interval} week";

                            $wkst  = (isset($rrules['WKST']) && in_array($rrules['WKST'], array('SA', 'SU', 'MO'))) ? $rrules['WKST'] : $this->defaultWeekStart;
                            $aWeek = $this->weeks[$wkst];
                            $days  = array('SA' => 'Saturday', 'SU' => 'Sunday', 'MO' => 'Monday');

                            // Build list of days of week to add events
                            $weekdays = $aWeek;

                            if (isset($rrules['BYDAY']) && $rrules['BYDAY'] !== '') {
                                $byDays = explode(',', $rrules['BYDAY']);
                            } else {
                                // A textual representation of a day, two letters (e.g. SU)
                                $byDays = array(mb_substr(strtoupper($initialStart->format('D')), 0, 2));
                            }

                            // Get timestamp of first day of start week
                            $weekRecurringTimestamp = (strcasecmp($initialStart->format('l'), $this->weekdays[$wkst]) === 0)
                                ? $startTimestamp
                                : strtotime("last {$days[$wkst]} " . $initialStart->format('H:i:s'), $startTimestamp);

                            // Step through weeks
                            while ($weekRecurringTimestamp <= $until) {
                                $dayRecurringTimestamp = $weekRecurringTimestamp;

                                // Adjust time zone from initial event
                                $dayRecurringOffset = 0;
                                if ($this->useTimeZoneWithRRules) {
                                    $dayRecurringTimeZone = \DateTime::createFromFormat(self::UNIX_FORMAT, $dayRecurringTimestamp);
                                    $dayRecurringTimeZone->setTimezone($initialStart->getTimezone());
                                    $dayRecurringOffset = $dayRecurringTimeZone->getOffset();
                                    $dayRecurringTimestamp += $dayRecurringOffset;
                                }

                                foreach ($weekdays as $day) {
                                    // Check if day should be added
                                    if (in_array($day, $byDays) && $dayRecurringTimestamp > $startTimestamp
                                        && $dayRecurringTimestamp <= $until
                                    ) {
                                        // Add event
                                        $anEvent['DTSTART'] = date(self::DATE_TIME_FORMAT, $dayRecurringTimestamp) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');
                                        $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                        $anEvent['DTSTART_array'][2] = $dayRecurringTimestamp;
                                        $anEvent['DTEND_array']      = $anEvent['DTSTART_array'];
                                        $anEvent['DTEND_array'][2]  += $eventTimestampOffset;
                                        $anEvent['DTEND'] = date(
                                            self::DATE_TIME_FORMAT,
                                            $anEvent['DTEND_array'][2]
                                        ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');
                                        $anEvent['DTEND_array'][1] = $anEvent['DTEND'];

                                        // Exclusions
                                        $isExcluded = array_filter($exdates, function ($exdate) use ($anEvent, $dayRecurringOffset) {
                                            return self::isExdateMatch($exdate, $anEvent, $dayRecurringOffset);
                                        });

                                        if (isset($anEvent['UID'])) {
                                            $searchDate = $anEvent['DTSTART'];
                                            if (isset($anEvent['DTSTART_array'][0]['TZID'])) {
                                                $searchDate = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $anEvent['DTSTART_array'][0]['TZID']) . $searchDate;
                                            }

                                            if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                $searchDateUtc = $this->iCalDateToUnixTimestamp($searchDate, true, true);
                                                if (in_array($searchDateUtc, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                    $isExcluded = true;
                                                }
                                            }
                                        }

                                        if (!$isExcluded) {
                                            $anEvent            = $this->processEventIcalDateTime($anEvent);
                                            $recurrenceEvents[] = $anEvent;
                                            $this->eventCount++;

                                            // If RRULE[COUNT] is reached then break
                                            if (isset($rrules['COUNT'])) {
                                                $countNb++;

                                                if ($countNb >= $countOrig) {
                                                    break 2;
                                                }
                                            }
                                        }
                                    }

                                    // Move forwards a day
                                    $dayRecurringTimestamp = strtotime('+1 day', $dayRecurringTimestamp);
                                }

                                // Move forwards $interval weeks
                                $weekRecurringTimestamp = strtotime($offset, $weekRecurringTimestamp);
                            }

                            $recurrenceEvents    = $this->trimToRecurrenceCount($rrules, $recurrenceEvents);
                            $allRecurrenceEvents = array_merge($allRecurrenceEvents, $recurrenceEvents);
                            $recurrenceEvents    = array(); // Reset
                            break;

                        case 'MONTHLY':
                            // Create offset
                            $recurringTimestamp = $startTimestamp;
                            $offset = "+{$interval} month";

                            if (isset($rrules['BYMONTHDAY']) && $rrules['BYMONTHDAY'] !== '') {
                                // Deal with BYMONTHDAY
                                $monthdays = explode(',', $rrules['BYMONTHDAY']);

                                while ($recurringTimestamp <= $until) {
                                    foreach ($monthdays as $key => $monthday) {
                                        $monthRecurringTimestamp = null;

                                        if ($key === 0) {
                                            // Ensure original event conforms to monthday rule
                                            $anEvent['DTSTART'] = gmdate(
                                                'Ym' . sprintf('%02d', $monthday) . '\T' . self::TIME_FORMAT,
                                                strtotime($anEvent['DTSTART'])
                                            ) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');

                                            $anEvent['DTEND'] = gmdate(
                                                'Ym' . sprintf('%02d', $monthday) . '\T' . self::TIME_FORMAT,
                                                isset($anEvent['DURATION'])
                                                        ? $this->parseDuration($anEvent['DTSTART'], end($anEvent['DURATION_array']))
                                                        : strtotime($anEvent['DTEND'])
                                            ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');

                                            $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                            $anEvent['DTSTART_array'][2] = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
                                            $anEvent['DTEND_array'][1]   = $anEvent['DTEND'];
                                            $anEvent['DTEND_array'][2]   = $this->iCalDateToUnixTimestamp($anEvent['DTEND']);

                                            // Ensure recurring timestamp confirms to BYMONTHDAY rule
                                            $monthRecurringTimestamp = $this->iCalDateToUnixTimestamp(
                                                gmdate(
                                                    'Ym' . sprintf('%02d', $monthday) . '\T' . self::TIME_FORMAT,
                                                    $recurringTimestamp
                                                ) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '')
                                            );
                                        }

                                        // Adjust time zone from initial event
                                        $monthRecurringOffset = 0;
                                        if ($this->useTimeZoneWithRRules) {
                                            $recurringTimeZone = \DateTime::createFromFormat(self::UNIX_FORMAT, $monthRecurringTimestamp);
                                            $recurringTimeZone->setTimezone($initialStart->getTimezone());
                                            $monthRecurringOffset = $recurringTimeZone->getOffset();
                                            $monthRecurringTimestamp += $monthRecurringOffset;
                                        }

                                        if (($monthRecurringTimestamp > $startTimestamp) && ($monthRecurringTimestamp <= $until)) {
                                            // Add event
                                            $anEvent['DTSTART'] = date(
                                                'Ym' . sprintf('%02d', $monthday) . '\T' . self::TIME_FORMAT,
                                                $monthRecurringTimestamp
                                            ) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');
                                            $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                            $anEvent['DTSTART_array'][2] = $monthRecurringTimestamp;
                                            $anEvent['DTEND_array']      = $anEvent['DTSTART_array'];
                                            $anEvent['DTEND_array'][2]  += $eventTimestampOffset;
                                            $anEvent['DTEND'] = date(
                                                self::DATE_TIME_FORMAT,
                                                $anEvent['DTEND_array'][2]
                                            ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');
                                            $anEvent['DTEND_array'][1] = $anEvent['DTEND'];

                                            // Exclusions
                                            $isExcluded = array_filter($exdates, function ($exdate) use ($anEvent, $monthRecurringOffset) {
                                                return self::isExdateMatch($exdate, $anEvent, $monthRecurringOffset);
                                            });

                                            if (isset($anEvent['UID'])) {
                                                $searchDate = $anEvent['DTSTART'];
                                                if (isset($anEvent['DTSTART_array'][0]['TZID'])) {
                                                    $searchDate = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $anEvent['DTSTART_array'][0]['TZID']) . $searchDate;
                                                }

                                                if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                    $searchDateUtc = $this->iCalDateToUnixTimestamp($searchDate, true, true);
                                                    if (in_array($searchDateUtc, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                        $isExcluded = true;
                                                    }
                                                }
                                            }

                                            if (!$isExcluded) {
                                                $anEvent = $this->processEventIcalDateTime($anEvent);
                                                $recurrenceEvents[] = $anEvent;
                                                $this->eventCount++;

                                                // If RRULE[COUNT] is reached then break
                                                if (isset($rrules['COUNT'])) {
                                                    $countNb++;

                                                    if ($countNb >= $countOrig) {
                                                        break 2;
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    // Move forwards
                                    $recurringTimestamp = strtotime($offset, $recurringTimestamp);
                                }
                            } elseif (isset($rrules['BYDAY']) && $rrules['BYDAY'] !== '') {
                                while ($recurringTimestamp <= $until) {
                                    $monthRecurringTimestamp = $recurringTimestamp;

                                    // Adjust time zone from initial event
                                    $monthRecurringOffset = 0;

                                    if ($this->useTimeZoneWithRRules) {
                                        $recurringTimeZone = \DateTime::createFromFormat(self::UNIX_FORMAT, $monthRecurringTimestamp);
                                        $recurringTimeZone->setTimezone($initialStart->getTimezone());
                                        $monthRecurringOffset = $recurringTimeZone->getOffset();
                                        $monthRecurringTimestamp += $monthRecurringOffset;
                                    }

                                    $eventStartDesc = "{$this->convertDayOrdinalToPositive($dayNumber, $weekday, $monthRecurringTimestamp)} {$this->weekdays[$weekday]} of "
                                        . date(self::DATE_TIME_FORMAT_PRETTY, $monthRecurringTimestamp);
                                    $eventStartTimestamp = strtotime($eventStartDesc);

                                    if (intval($rrules['BYDAY']) === 0) {
                                        $lastDayDesc = "last {$this->weekdays[$weekday]} of "
                                            . date(self::DATE_TIME_FORMAT_PRETTY, $monthRecurringTimestamp);
                                    } else {
                                        $lastDayDesc = "{$this->convertDayOrdinalToPositive($dayNumber, $weekday, $monthRecurringTimestamp)} {$this->weekdays[$weekday]} of "
                                            . date(self::DATE_TIME_FORMAT_PRETTY, $monthRecurringTimestamp);
                                    }

                                    $lastDayTimestamp = strtotime($lastDayDesc);

                                    do {
                                        // Prevent 5th day of a month from showing up on the next month
                                        // If BYDAY and the event falls outside the current month, skip the event

                                        $compareCurrentMonth = date('F', $monthRecurringTimestamp);
                                        $compareEventMonth   = date('F', $eventStartTimestamp);

                                        if ($compareCurrentMonth !== $compareEventMonth) {
                                            $monthRecurringTimestamp = strtotime($offset, $monthRecurringTimestamp);
                                            continue;
                                        }

                                        if ($eventStartTimestamp > $startTimestamp && $eventStartTimestamp <= $until) {
                                            $anEvent['DTSTART'] = date(self::DATE_TIME_FORMAT, $eventStartTimestamp) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');
                                            $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                            $anEvent['DTSTART_array'][2] = $eventStartTimestamp;
                                            $anEvent['DTEND_array']      = $anEvent['DTSTART_array'];
                                            $anEvent['DTEND_array'][2]  += $eventTimestampOffset;
                                            $anEvent['DTEND'] = date(
                                                self::DATE_TIME_FORMAT,
                                                $anEvent['DTEND_array'][2]
                                            ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');
                                            $anEvent['DTEND_array'][1] = $anEvent['DTEND'];

                                            // Exclusions
                                            $isExcluded = array_filter($exdates, function ($exdate) use ($anEvent, $monthRecurringOffset) {
                                                return self::isExdateMatch($exdate, $anEvent, $monthRecurringOffset);
                                            });

                                            if (isset($anEvent['UID'])) {
                                                $searchDate = $anEvent['DTSTART'];
                                                if (isset($anEvent['DTSTART_array'][0]['TZID'])) {
                                                    $searchDate = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $anEvent['DTSTART_array'][0]['TZID']) . $searchDate;
                                                }

                                                if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                    $searchDateUtc = $this->iCalDateToUnixTimestamp($searchDate, true, true);
                                                    if (in_array($searchDateUtc, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                        $isExcluded = true;
                                                    }
                                                }
                                            }

                                            if (!$isExcluded) {
                                                $anEvent            = $this->processEventIcalDateTime($anEvent);
                                                $recurrenceEvents[] = $anEvent;
                                                $this->eventCount++;

                                                // If RRULE[COUNT] is reached then break
                                                if (isset($rrules['COUNT'])) {
                                                    $countNb++;

                                                    if ($countNb >= $countOrig) {
                                                        break 2;
                                                    }
                                                }
                                            }
                                        }

                                        if (isset($rrules['BYSETPOS'])) {
                                            // BYSETPOS is defined so skip
                                            // looping through each week
                                            $lastDayTimestamp = $eventStartTimestamp;
                                        }

                                        $eventStartTimestamp += self::SECONDS_IN_A_WEEK;
                                    } while ($eventStartTimestamp <= $lastDayTimestamp);

                                    // Move forwards
                                    $recurringTimestamp = strtotime($offset, $recurringTimestamp);
                                }
                            }

                            $recurrenceEvents    = $this->trimToRecurrenceCount($rrules, $recurrenceEvents);
                            $allRecurrenceEvents = array_merge($allRecurrenceEvents, $recurrenceEvents);
                            $recurrenceEvents    = array(); // Reset
                            break;

                        case 'YEARLY':
                            // Create offset
                            $recurringTimestamp = $startTimestamp;
                            $offset = "+{$interval} year";

                            // Deal with BYMONTH
                            if (isset($rrules['BYMONTH']) && $rrules['BYMONTH'] !== '') {
                                $bymonths = explode(',', $rrules['BYMONTH']);
                            } else {
                                $bymonths = array();
                            }

                            // Check if BYDAY rule exists
                            if (isset($rrules['BYDAY']) && $rrules['BYDAY'] !== '') {
                                while ($recurringTimestamp <= $until) {
                                    $yearRecurringTimestamp = $recurringTimestamp;

                                    // Adjust time zone from initial event
                                    $yearRecurringOffset = 0;

                                    if ($this->useTimeZoneWithRRules) {
                                        $recurringTimeZone = \DateTime::createFromFormat(self::UNIX_FORMAT, $yearRecurringTimestamp);
                                        $recurringTimeZone->setTimezone($initialStart->getTimezone());
                                        $yearRecurringOffset = $recurringTimeZone->getOffset();
                                        $yearRecurringTimestamp += $yearRecurringOffset;
                                    }

                                    foreach ($bymonths as $bymonth) {
                                        $eventStartDesc = "{$this->convertDayOrdinalToPositive($dayNumber, $weekday, $yearRecurringTimestamp)} {$this->weekdays[$weekday]}"
                                            . " of {$this->monthNames[$bymonth]} "
                                            . gmdate('Y H:i:s', $yearRecurringTimestamp);
                                        $eventStartTimestamp = strtotime($eventStartDesc);

                                        if (intval($rrules['BYDAY']) === 0) {
                                            $lastDayDesc = "last {$this->weekdays[$weekday]}"
                                                . " of {$this->monthNames[$bymonth]} "
                                                . gmdate('Y H:i:s', $yearRecurringTimestamp);
                                        } else {
                                            $lastDayDesc = "{$this->convertDayOrdinalToPositive($dayNumber, $weekday, $yearRecurringTimestamp)} {$this->weekdays[$weekday]}"
                                                . " of {$this->monthNames[$bymonth]} "
                                                . gmdate('Y H:i:s', $yearRecurringTimestamp);
                                        }

                                        $lastDayTimestamp = strtotime($lastDayDesc);

                                        do {
                                            if ($eventStartTimestamp > $startTimestamp && $eventStartTimestamp <= $until) {
                                                $anEvent['DTSTART'] = date(self::DATE_TIME_FORMAT, $eventStartTimestamp) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');
                                                $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                                $anEvent['DTSTART_array'][2] = $eventStartTimestamp;
                                                $anEvent['DTEND_array']      = $anEvent['DTSTART_array'];
                                                $anEvent['DTEND_array'][2]  += $eventTimestampOffset;
                                                $anEvent['DTEND'] = date(
                                                    self::DATE_TIME_FORMAT,
                                                    $anEvent['DTEND_array'][2]
                                                ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');
                                                $anEvent['DTEND_array'][1] = $anEvent['DTEND'];

                                                // Exclusions
                                                $isExcluded = array_filter($exdates, function ($exdate) use ($anEvent, $yearRecurringOffset) {
                                                    return self::isExdateMatch($exdate, $anEvent, $yearRecurringOffset);
                                                });

                                                if (isset($anEvent['UID'])) {
                                                    $searchDate = $anEvent['DTSTART'];
                                                    if (isset($anEvent['DTSTART_array'][0]['TZID'])) {
                                                        $searchDate = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $anEvent['DTSTART_array'][0]['TZID']) . $searchDate;
                                                    }

                                                    if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                        $searchDateUtc = $this->iCalDateToUnixTimestamp($searchDate, true, true);
                                                        if (in_array($searchDateUtc, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                            $isExcluded = true;
                                                        }
                                                    }
                                                }

                                                if (!$isExcluded) {
                                                    $anEvent            = $this->processEventIcalDateTime($anEvent);
                                                    $recurrenceEvents[] = $anEvent;
                                                    $this->eventCount++;

                                                    // If RRULE[COUNT] is reached then break
                                                    if (isset($rrules['COUNT'])) {
                                                        $countNb++;

                                                        if ($countNb >= $countOrig) {
                                                            break 3;
                                                        }
                                                    }
                                                }
                                            }

                                            $eventStartTimestamp += self::SECONDS_IN_A_WEEK;
                                        } while ($eventStartTimestamp <= $lastDayTimestamp);
                                    }

                                    // Move forwards
                                    $recurringTimestamp = strtotime($offset, $recurringTimestamp);
                                }
                            } else {
                                $day = $initialStart->format('d');

                                // Step through years
                                while ($recurringTimestamp <= $until) {
                                    $yearRecurringTimestamp = $recurringTimestamp;

                                    // Adjust time zone from initial event
                                    $yearRecurringOffset = 0;
                                    if ($this->useTimeZoneWithRRules) {
                                        $recurringTimeZone = \DateTime::createFromFormat(self::UNIX_FORMAT, $yearRecurringTimestamp);
                                        $recurringTimeZone->setTimezone($initialStart->getTimezone());
                                        $yearRecurringOffset = $recurringTimeZone->getOffset();
                                        $yearRecurringTimestamp += $yearRecurringOffset;
                                    }

                                    $eventStartDescs = array();
                                    if (isset($rrules['BYMONTH']) && $rrules['BYMONTH'] !== '') {
                                        foreach ($bymonths as $bymonth) {
                                            array_push($eventStartDescs, "{$day} {$this->monthNames[$bymonth]} " . gmdate('Y H:i:s', $yearRecurringTimestamp));
                                        }
                                    } else {
                                        array_push($eventStartDescs, $day . gmdate(self::DATE_TIME_FORMAT_PRETTY, $yearRecurringTimestamp));
                                    }

                                    foreach ($eventStartDescs as $eventStartDesc) {
                                        $eventStartTimestamp = strtotime($eventStartDesc);

                                        if ($eventStartTimestamp > $startTimestamp && $eventStartTimestamp <= $until) {
                                            $anEvent['DTSTART'] = date(self::DATE_TIME_FORMAT, $eventStartTimestamp) . (($initialStartTimeZoneName === 'Z') ? 'Z' : '');
                                            $anEvent['DTSTART_array'][1] = $anEvent['DTSTART'];
                                            $anEvent['DTSTART_array'][2] = $eventStartTimestamp;
                                            $anEvent['DTEND_array']      = $anEvent['DTSTART_array'];
                                            $anEvent['DTEND_array'][2]  += $eventTimestampOffset;
                                            $anEvent['DTEND'] = date(
                                                self::DATE_TIME_FORMAT,
                                                $anEvent['DTEND_array'][2]
                                            ) . (($initialEndTimeZoneName === 'Z') ? 'Z' : '');
                                            $anEvent['DTEND_array'][1] = $anEvent['DTEND'];

                                            // Exclusions
                                            $isExcluded = array_filter($exdates, function ($exdate) use ($anEvent, $yearRecurringOffset) {
                                                return self::isExdateMatch($exdate, $anEvent, $yearRecurringOffset);
                                            });

                                            if (isset($anEvent['UID'])) {
                                                $searchDate = $anEvent['DTSTART'];
                                                if (isset($anEvent['DTSTART_array'][0]['TZID'])) {
                                                    $searchDate = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $anEvent['DTSTART_array'][0]['TZID']) . $searchDate;
                                                }

                                                if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                    $searchDateUtc = $this->iCalDateToUnixTimestamp($searchDate, true, true);
                                                    if (in_array($searchDateUtc, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
                                                        $isExcluded = true;
                                                    }
                                                }
                                            }

                                            if (!$isExcluded) {
                                                $anEvent            = $this->processEventIcalDateTime($anEvent);
                                                $recurrenceEvents[] = $anEvent;
                                                $this->eventCount++;

                                                // If RRULE[COUNT] is reached then break
                                                if (isset($rrules['COUNT'])) {
                                                    $countNb++;

                                                    if ($countNb >= $countOrig) {
                                                        break 2;
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    // Move forwards
                                    $recurringTimestamp = strtotime($offset, $recurringTimestamp);
                                }
                            }

                            $recurrenceEvents    = $this->trimToRecurrenceCount($rrules, $recurrenceEvents);
                            $allRecurrenceEvents = array_merge($allRecurrenceEvents, $recurrenceEvents);
                            $recurrenceEvents    = array(); // Reset
                            break;
                    }
                }
            }

            $events = array_merge($events, $allRecurrenceEvents);

            $this->cal['VEVENT'] = $events;
        }
    }
726498
def itermonthdays2(cls, year, month):
        
        for day in NepCal.itermonthdates(year, month):
            if day.month == month:
                yield (day.day, day.weekday())
            else:
                yield (0, day.weekday())
891923
function(eventName, cpuNumber, pid, ts, eventBase) {
      var event = /frequency=(\d+)/.exec(eventBase.details);
      if (!event)
        return false;

      this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1]));
      return true;
    }
305202
private void computePeriod(InfoTree it1, int aVp, int aNextVp, InfoTree it2, int aStrategy) {

		int fTreeSize = it1.getSize();
		int gTreeSize = it2.getSize();

		int vpPreorder = it1.info[POST2_PRE][aVp];
		int vpRevPreorder = fTreeSize - 1 - aVp;
		int vpSize = it1.info[POST2_SIZE][aVp];

		int gSize = it2.info[POST2_SIZE][it2.getCurrentNode()];
		int gPreorder = it2.info[POST2_PRE][it2.getCurrentNode()];
		int gRevPreorder = gTreeSize - 1 - it2.getCurrentNode();

		int nextVpPreorder = -1;
		int nextVpRevPreorder = -1;
		int nextVpSize = -1;
		// count k and assign next vp values
		int k;
		if (aNextVp != -1) {
			nextVpPreorder = it1.info[POST2_PRE][aNextVp];
			nextVpRevPreorder = fTreeSize - 1 - aNextVp;
			nextVpSize = it1.info[POST2_SIZE][aNextVp];
			// if strategy==LEFT use preorder to count number of left deletions from vp to
			// vp-1
			// if strategy==RIGHT use reversed preorder
			k = aStrategy == LEFT ? nextVpPreorder - vpPreorder
					: nextVpRevPreorder - vpRevPreorder;
			if (aStrategy != previousStrategy) {
				computeIJTable(it2, gPreorder, gRevPreorder, gSize, aStrategy, gTreeSize);
			}
		} else {
			k = 1;
			computeIJTable(it2, gPreorder, gRevPreorder, gSize, aStrategy, gTreeSize);
		}

		int realStrategy = it1.info[POST2_STRATEGY][aVp];

		boolean switched = it1.isSwitched();

		double[][] tTable_copy = t.clone();

		// Q and T are visible for every i
		double[] qTable = new double[k];

		// if aVp is a leaf => precompute table T - edit distance betwen EMPTY and all
		// subforests of G

		// check if nextVp is the only child of vp
		if (vpSize - nextVpSize == 1) {
			// update delta from T table => dist between Fvp-1 and G was computed in
			// previous compute period
			if (gSize == 1) {
				setDeltaValue(it1.info[PRE2_POST][vpPreorder], it2.info[PRE2_POST][gPreorder],
						vpSize - 1, switched);
			} else {
				setDeltaValue(it1.info[PRE2_POST][vpPreorder], it2.info[PRE2_POST][gPreorder],
						t[1][0], switched);
			}
		}

		double[][] sTable;// = new double[k][gTreeSize+1];

		int gijForestPreorder;
		int previousI;
		int fForestPreorderKPrime;
		int jPrime;
		int kBis;
		int jOfIminus1;
		int gijOfIMinus1Preorder;
		int jOfI;
		double deleteFromLeft;
		double deleteFromRight;
		double match;
		int fLabel;
		int gLabel;

		// Q and T are visible for every i
		for (int i = gSize - 1; i >= 0; i--) {

			// jOfI was already computed once in spfH
			jOfI = jOfI(it2, i, gSize, gRevPreorder, gPreorder, aStrategy, gTreeSize);

			// when strategy==BOTH first LEFT then RIGHT is done

			counter += realStrategy == BOTH && aStrategy == LEFT ? (k - 1) * (jOfI + 1)
					: k * (jOfI + 1);

			// compute table S - visible for actual i

			sTable = new double[k][jOfI + 1]; // initialized outside loop? -> doesn't work

			for (int kPrime = 1; kPrime <= k; kPrime++) {

				fForestPreorderKPrime = aStrategy == LEFT ? vpPreorder + (k - kPrime)
						: it1.info[POST2_PRE][fTreeSize - 1 - (vpRevPreorder + (k - kPrime))];
				kBis = kPrime - it1.info[POST2_SIZE][it1.info[PRE2_POST][fForestPreorderKPrime]];

				// reset the minimum arguments' values
				deleteFromRight = costIns;
				deleteFromLeft = costDel;
				match = 0;

				match += aStrategy == LEFT ? kBis + nextVpSize : vpSize - k + kBis;

				if ((i + jOfI) == (gSize - 1)) {
					deleteFromRight += (vpSize - (k - kPrime));
				} else {
					deleteFromRight += qTable[kPrime - 1];
				}

				fLabel = it1.info[POST2_LABEL][it1.info[PRE2_POST][fForestPreorderKPrime]];

				for (int j = jOfI; j >= 0; j--) {
					// count dist(FkPrime, Gij) with min

					// delete from left

					gijForestPreorder = aStrategy == LEFT ? IJ[i][j]
							: it2.info[POST2_PRE][gTreeSize - 1 - IJ[i][j]];

					if (kPrime == 1) {
						// if the direction changed from the previous period to this one use i and j
						// of
						// previous strategy

						// since T is overwritten continously, thus use T_copy for getting values
						// from
						// previous period

						if (aStrategy != previousStrategy) {
							if (aStrategy == LEFT) {
								previousI = gijForestPreorder - gPreorder; // minus preorder of G
							} else {
								previousI = gTreeSize - 1
										- it2.info[RPOST2_POST][gTreeSize - 1 - gijForestPreorder]
										- gRevPreorder; // minus rev preorder of G
							}
							deleteFromLeft += tTable_copy[previousI][i + j - previousI];
						} else {
							deleteFromLeft += tTable_copy[i][j];
						}

					} else {
						deleteFromLeft += sTable[kPrime - 1 - 1][j];
					}

					// match

					match += switched
							?
							delta[it2.info[PRE2_POST][gijForestPreorder]][it1.info[PRE2_POST][fForestPreorderKPrime]]
							:
							delta[it1.info[PRE2_POST][fForestPreorderKPrime]][it2.info[PRE2_POST][gijForestPreorder]];

					jPrime = j + it2.info[POST2_SIZE][it2.info[PRE2_POST][gijForestPreorder]];

					// if root nodes of L/R Fk' and L/R Gij have different labels add the match cost
					gLabel = it2.info[POST2_LABEL][it2.info[PRE2_POST][gijForestPreorder]];

					if (fLabel != gLabel) {
						match += costMatch;
					}

					// this condition is checked many times but is not satisfied only once
					if (j != jOfI) {
						// delete from right
						deleteFromRight += sTable[kPrime - 1][j + 1];
						if (kBis == 0) {
							if (aStrategy != previousStrategy) {
								previousI = aStrategy == LEFT ? IJ[i][jPrime] - gPreorder
										: IJ[i][jPrime] - gRevPreorder;
								match += tTable_copy[previousI][i + jPrime - previousI];
							} else {
								match += tTable_copy[i][jPrime];
							}
						} else if (kBis > 0) {
							match += sTable[kBis - 1][jPrime];
						} else {
							match += gSize - (i + jPrime);
						}

					}

					// fill S table
					sTable[kPrime - 1][j] = (deleteFromLeft < deleteFromRight)
							? ((deleteFromLeft < match) ? deleteFromLeft : match)
							: ((deleteFromRight < match) ? deleteFromRight : match);

					// reset the minimum arguments' values
					deleteFromRight = costIns;
					deleteFromLeft = costDel;
					match = 0;
				}
			}

			// compute table T => add row to T
			if (realStrategy == BOTH && aStrategy == LEFT) {
				t[i] = sTable[k - 1 - 1];
			} else {
				t[i] = sTable[k - 1];
			}

			if (i > 0) {
				// compute table Q
				jOfIminus1 =
						jOfI(it2, i - 1, gSize, gRevPreorder, gPreorder, aStrategy, gTreeSize);
				if (jOfIminus1 <= jOfI) {
					for (int x = 0;
					     x < qTable.length; x++) { // copy whole column | qTable.length=k
						qTable[x] = sTable[x][jOfIminus1];
					}
				}

				// fill table delta
				if (i + jOfIminus1 < gSize) {

					gijOfIMinus1Preorder = aStrategy == LEFT
							? it2.info[POST2_PRE][gTreeSize - 1 - (gRevPreorder + (i - 1))]
							: gPreorder + (i - 1);

					// If Fk from Fk-1 differ with a single node,
					// then Fk without the root node is Fk-1 and the distance value has to be taken
					// from previous T table.
					if (k - 1 - 1 < 0) {
						if (aStrategy != previousStrategy) {
							previousI = aStrategy == LEFT ? IJ[i][jOfIminus1] - gPreorder
									: IJ[i][jOfIminus1] - gRevPreorder;
							setDeltaValue(it1.info[PRE2_POST][vpPreorder],
									it2.info[PRE2_POST][gijOfIMinus1Preorder],
									tTable_copy[previousI][i + jOfIminus1 - previousI], switched);
						} else {
							setDeltaValue(it1.info[PRE2_POST][vpPreorder],
									it2.info[PRE2_POST][gijOfIMinus1Preorder],
									tTable_copy[i][jOfIminus1], switched);
						}
					} else {
						setDeltaValue(it1.info[PRE2_POST][vpPreorder],
								it2.info[PRE2_POST][gijOfIMinus1Preorder],
								sTable[k - 1 - 1][jOfIminus1], switched);
					}
				}
			}

		}
		previousStrategy = aStrategy;
	}
1226491
private void processRanges(List<DateRange> ranges, ProjectCalendarDateRanges container)
   {
      if (ranges != null)
      {
         for (DateRange range : ranges)
         {
            container.addRange(range);
         }
      }
   }
289563
def finish(self, data=''):
        '''
        
        '''
        self.pending += data
        self.streaming = False
        for i in self:
            yield i
882574
private void process(Iterator<String> tokens) {
        // NOTE: this method is intentionally private to ensure that the
        // IteratorFactory.tokenize() tokenization scheme is enforced on the
        // input data
        long numTokens = 0;
        while (tokens.hasNext()) {
            String token = tokens.next();
            if (doLowerCasing)
                token = token.toLowerCase();
            if (token.matches("[0-9]+"))
                token = "<NUM>";
            if (token.matches("[^\\w\\s;:\\(\\)\\[\\]'!/&?\",\\.<>]"))
                continue;

            Integer count = tokenToCount.get(token);
            tokenToCount.put(token, (count == null) ? 1 : 1 + count);
            numTokens++;
            if (numTokens % UPDATE_INTERVAL == 0 
                    && LOGGER.isLoggable(Level.FINE))
                LOGGER.fine("Processed " + numTokens + " tokens.  Currently " 
                            + tokenToCount.size() + " unique tokens");
        }
    }
79377
private void processCalendarDays(ProjectCalendar calendar, Record root)
   {
      // Retrieve working hours ...
      Record daysOfWeek = root.getChild("DaysOfWeek");
      if (daysOfWeek != null)
      {
         for (Record dayRecord : daysOfWeek.getChildren())
         {
            processCalendarHours(calendar, dayRecord);
         }
      }
   }
1311936
private void getMonthlyRelativeDates(Calendar calendar, int frequency, List<Date> dates)
   {
      long startDate = calendar.getTimeInMillis();
      calendar.set(Calendar.DAY_OF_MONTH, 1);
      int dayNumber = NumberHelper.getInt(m_dayNumber);

      while (moreDates(calendar, dates))
      {
         if (dayNumber > 4)
         {
            setCalendarToLastRelativeDay(calendar);
         }
         else
         {
            setCalendarToOrdinalRelativeDay(calendar, dayNumber);
         }

         if (calendar.getTimeInMillis() > startDate)
         {
            dates.add(calendar.getTime());
            if (!moreDates(calendar, dates))
            {
               break;
            }
         }
         calendar.set(Calendar.DAY_OF_MONTH, 1);
         calendar.add(Calendar.MONTH, frequency);
      }
   }
328312
def _iter_withprogress(iterable, progress, log):
    """"""
    before_all = time.time()
    before = before_all
    n = 0
    for i, o in enumerate(iterable):
        yield o
        n = i+1
        if n % progress == 0:
            after = time.time()
            log('%s rows in %.2fs; batch in %.2fs (%d rows/s)'
                % (n, after-before_all, after-before, progress/(after-before)))
            before = after
    after_all = time.time()
    log('%s rows in %.2fs (%d rows/s)'
        % (n, after_all-before_all, n/(after_all-before_all)))
1270779
private Integer getFrequency(Project.Calendars.Calendar.Exceptions.Exception exception)
   {
      Integer period = NumberHelper.getInteger(exception.getPeriod());
      if (period == null)
      {
         period = Integer.valueOf(1);
      }
      return period;
   }
674386
public void advanceTo(DateValue dateUtc) {
        // Don't throw away a future pending date since the iterators will not
        // generate it again.
        if (this.pendingUtc_ != null && dateUtc.compareTo(this.pendingUtc_) <= 0) {
            return;
        }

        DateValue dateLocal = TimeUtils.fromUtc(dateUtc, tzid_);
        // Short-circuit if we're already past dateUtc.
        if (dateLocal.compareTo(this.builder_.toDate()) <= 0) {
            return;
        }
        this.pendingUtc_ = null;

        try {
            if (this.canShortcutAdvance_) {
                // skip years before date.year
                if (this.builder_.year < dateLocal.year()) {
                    do {
                        if (!this.yearGenerator_.generate(this.builder_)) {
                            this.done_ = true;
                            return;
                        }
                    } while (this.builder_.year < dateLocal.year());
                    while (!this.monthGenerator_.generate(this.builder_)) {
                        if (!this.yearGenerator_.generate(this.builder_)) {
                            this.done_ = true;
                            return;
                        }
                    }
                }
                // skip months before date.year/date.month
                while (this.builder_.year == dateLocal.year()
                        && this.builder_.month < dateLocal.month()) {
                    while (!this.monthGenerator_.generate(this.builder_)) {
                        // if there are more years available fetch one
                        if (!this.yearGenerator_.generate(this.builder_)) {
                            // otherwise the recurrence is exhausted
                            this.done_ = true;
                            return;
                        }
                    }
                }
            }

            // consume any remaining instances
            while (!this.done_) {
                DateValue dUtc = this.generateInstance();
                if (null == dUtc) {
                    this.done_ = true;
                } else {
                    if (!this.condition_.apply(dUtc)) {
                        this.done_ = true;
                    } else if (dUtc.compareTo(dateUtc) >= 0) {
                        this.pendingUtc_ = dUtc;
                        break;
                    }
                }
            }
        } catch (Generator.IteratorShortCircuitingException ex) {
            this.done_ = true;
        }
    }