Check if an hour is under a frequency frame and should not be displayed.

@param $hour String hour value in string
@param $frequencies Array of frequency entities
@param $hours array as returned by this->calendarRange
332016
public function isWithinFrequency($hour, $frequencies, $hours)
    {
        $hourIndex = $this->getIndex($hour, $hours);
        foreach ($frequencies as $frequency) {
            $startIndex = $this->getIndex(date('G', $frequency->getStartTime()->getTimestamp()), $hours);
            $endIndex = $this->getIndex(date('G', $frequency->getEndTime()->getTimestamp()), $hours);
            if ($hourIndex >= $startIndex && $hourIndex <= $endIndex) {
                return true;
            }
        }

        return false;
    }
1195926
public function activeFrequency($frequency, $actualFrequency){
        $frequency= explode(' ', trim($frequency, ' '));        
        $condition= $this->validInterval($frequency[0], $actualFrequency['i']) && $this->validInterval($frequency[1], $actualFrequency['H']) 
                && $this->validInterval($frequency[2], $actualFrequency['d']) && $this->validInterval($frequency[3], $actualFrequency['m']) 
                && $this->validInterval($frequency[4], $actualFrequency['w']);
        return $condition;
    }
815697
private function validateCronSequence($minute = null, $hour = null, $day = null, $month = null, $weekday = null)
    {
        return [
            'minute' => $this->validateCronRange($minute, 0, 59),
            'hour' => $this->validateCronRange($hour, 0, 23),
            'day' => $this->validateCronRange($day, 1, 31),
            'month' => $this->validateCronRange($month, 1, 12),
            'weekday' => $this->validateCronRange($weekday, 0, 6),
        ];
    }
217185
public static function isThisWeek($time): bool
    {
        return (self::factory($time)->format('W-Y') === self::factory()->format('W-Y'));
    }
532309
public static function wasLastWeek($time) {
        $start = static::factory('last week 00:00:00');

        $end = clone $start;
        $end->modify('next week -1 second');

        $time = static::factory($time);

        return ($time >= $start && $time <= $end);
    }
607921
public function weekly($weekday = 0, $hour = 0, $minute = 0)
    {
        if (is_string($hour)) {
            $parts = explode(':', $hour);
            $hour = $parts[0];
            $minute = isset($parts[1]) ? $parts[1] : '0';
        }

        $c = $this->validateCronSequence($minute, $hour, null, null, $weekday);

        return $this->at("{$c['minute']} {$c['hour']} * * {$c['weekday']}");
    }
872954
public function set_hour($hour) {
        if ($hour === 'R') {
            $hour = mt_rand(self::HOURMIN, self::HOURMAX);
        }
        $this->hour = $hour;
    }
1149683
public function hourly($diff)
    {
        if ($this->daily($diff) && ($diff->d == 0) && (($diff->h == 0) || (($diff->h == 1) && ($diff->i == 0)))) {
            return true;
        }
        return false;
    }
1348178
function setHMS( $hour, $min = 0, $sec = 0 )
    {
        $arr = getdate( $this->DateTime );
        $this->DateTime = mktime( $hour, $min, $sec,
                                  $arr['mon'], $arr['mday'], $arr['year'] );
    }
1048260
protected function guardTime(int $hour, int $minute, int $second): void
    {
        if ($hour < static::MIN_HOUR || $hour > static::MAX_HOUR) {
            $message = sprintf('Hour (%d) out of range[%d, %d]', $hour, static::MIN_HOUR, static::MAX_HOUR);
            throw new DomainException($message);
        }

        if ($minute < static::MIN_MINUTE || $minute > static::MAX_MINUTE) {
            $message = sprintf('Minute (%d) out of range[%d, %d]', $minute, static::MIN_MINUTE, static::MAX_MINUTE);
            throw new DomainException($message);
        }

        if ($second < static::MIN_SECOND || $second > static::MAX_SECOND) {
            $message = sprintf('Second (%d) out of range[%d, %d]', $second, static::MIN_SECOND, static::MAX_SECOND);
            throw new DomainException($message);
        }
    }
1241930
static public function isValidTime($hour, $min, $sec, $hs24 = true)
    {
        if ($hs24 && ($hour < 0 || $hour > 23) || !$hs24 && ($hour < 1 || $hour > 12)) return false;
        if ($min > 59 || $min < 0) return false;
        if ($sec > 59 || $sec < 0) return false;
        return true;
    }
1123919
public static function repeatHourlyForTotalCount($count, $hours = 1) {
        if($count < 1) {
            throw new \InvalidArgumentException(sprintf('Total count of firings must be at least one! Given count: "%s"', $count));
        }

        return static::simpleSchedule()
            ->withIntervalInHours($hours)
            ->withRepeatCount($count - 1);
    }
118171
public function withHour(int $hour) : ZonedDateTime
    {
        return ZonedDateTime::of($this->localDateTime->withHour($hour), $this->timeZone);
    }
653091
public function setHour($hour)
    {
        if (!preg_match(self::$_regex['hour'], $hour)) {
            throw new \InvalidArgumentException(sprintf('Hour "%s" is incorect', $hour));
        }

        $this->hour = $hour;

        return $this->generateHash();
    }
956808
protected void setCalendarHour(Calendar cal, int hour) {
    cal.set(Calendar.HOUR_OF_DAY, hour);
    if (cal.get(Calendar.HOUR_OF_DAY) != hour && hour != 24) {
      cal.set(Calendar.HOUR_OF_DAY, hour + 1);
    }
  }
278371
public static function wasLastMonth($time) {
        $start = static::factory('first day of last month 00:00:00');

        $end = clone $start;
        $end->modify('next month -1 second');

        $time = static::factory($time);

        return ($time >= $start && $time <= $end);
    }
1179214
protected function prepareDateElements($limitRange = true)
    {
        // if the interval isn't set, set it.
        if (!isset($this->interval))
        {
            $this->interval = 1;
        }

        // must have a frequency
        if (!isset($this->freq) && Valid::byFreqValid($this->freq, $this->byweeknos, $this->byyeardays, $this->bymonthdays))
        {
            throw new FrequencyRequired();
        }

        if ($limitRange && !isset($this->count))
        {
            $this->count = $this->rangeLimit;
        }

        // "Similarly, if the BYMINUTE, BYHOUR, BYDAY,
        // BYMONTHDAY, or BYMONTH rule part were missing, the appropriate
        // minute, hour, day, or month would have been retrieved from the
        // "DTSTART" property."

        // if there is no startDate, make it now
        if (!$this->startDate)
        {
            $this->startDate = new DateTime();
        }

        // the calendar repeats itself every 400 years, so if a date
        // doesn't exist for 400 years, I don't think it will ever
        // occur
        if ($limitRange && !isset($this->until))
        {
            $this->until = new DateTime();
            $this->until->add(new DateInterval('P400Y'));
        }

        if (!isset($this->byminutes))
        {
            $this->byminutes = array((int)$this->startDate->format('i'));
        }

        if (!isset($this->byhours))
        {
            $this->byhours = array((int)$this->startDate->format('G'));
        }

        if (!isset($this->byseconds))
        {
            $this->byseconds = array((int)$this->startDate->format('s'));
        }

        if (!isset($this->wkst))
        {
            $this->wkst = "mo";
        }

        /*if (!isset($this->bydays))
        {
            $dayOfWeek = $this->startDate->format('l');
            $dayOfWeekAbr = strtolower(substr($dayOfWeek, 0, 2));
            $this->bydays = array($dayOfWeekAbr);
        }*/

        if ($this->freq === "monthly")
        {
            if (!isset($this->bymonthdays) && !isset($this->bydays))
            {
                $this->bymonthdays = array((int)$this->startDate->format('j'));
            }
        }

        if ($this->freq === "weekly")
        {
            if (!isset($this->bymonthdays) && !isset($this->bydays))
            {
                $dayOfWeek = $this->startDate->format('l');
                $dayOfWeekAbr = strtolower(substr($dayOfWeek, 0, 2));
                $this->bydays = array("0" . $dayOfWeekAbr);
            }
        }

        if ($this->freq === "yearly")
        {
            if (!isset($this->bydays) &&
                !isset($this->bymonths) &&
                !isset($this->bymonthdays) &&
                !isset($this->byyeardays) &&
                !isset($this->byweeknos) &&
                !isset($this->bysetpos))
            {
                $this->bymonth($this->startDate->format('n'));
            }
        }

    }