Determine if the Business has any published Vacancies available for booking.

@param string $fromDate
@param int $days

@return bool
199161
public function isBookable($fromDate = 'now', $days = 7)
    {
        $fromDate = Carbon::parse($fromDate)->timezone($this->business->timezone);

        $count = $this->business
                      ->vacancies()
                      ->future($fromDate)
                      ->until($fromDate->addDays($days))
                      ->count();

        return $count > 0;
    }
774509
public function dontSeeDateIsInDays($date, $days) {
        \PHPUnit_Framework_Assert::assertNotEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false));
    }
364329
public function byDays(int $days): Date
    {
        return $this->dayTo($this->originalDate->day() + $days);
    }
214362
private function reserveNextJobs(array $from_channels = null, $number_of_jobs_to_reserve = 1)
    {
        $reserved_job_ids = [];

        $timestamp = date('Y-m-d H:i:s');
        $channel_conditions = empty($from_channels) ? '' : $this->connection->prepareConditions(['`channel` IN ? AND ', $from_channels]);

        $limit = $number_of_jobs_to_reserve + 100;

        $job_ids = $this->connection->executeFirstColumn(
            'SELECT `id` 
                FROM `' . self::JOBS_TABLE_NAME . "` 
                WHERE {$channel_conditions}`reserved_at` IS NULL AND `available_at` <= ? 
                ORDER BY `priority` DESC, `id` 
                LIMIT 0, {$limit}",
            $timestamp
        );

        if (!empty($job_ids)) {
            foreach ($job_ids as $job_id) {
                $reservation_key = $this->prepareNewReservationKey();

                if ($this->on_reservation_key_ready) {
                    call_user_func($this->on_reservation_key_ready, $job_id, $reservation_key);
                }

                $this->connection->execute('UPDATE `' . self::JOBS_TABLE_NAME . '` SET `reservation_key` = ?, `reserved_at` = ? WHERE `id` = ? AND `reservation_key` IS NULL', $reservation_key, $timestamp, $job_id);

                if ($this->connection->affectedRows() === 1) {
                    $reserved_job_ids[] = $job_id;

                    if (count($reserved_job_ids) >= $number_of_jobs_to_reserve) {
                        break;
                    }
                }
            }
        }

        return $reserved_job_ids;
    }
206996
public function getStats($contactClientId, $type, $fromDate = null, $toDate = null)
    {
        $q = $this->createQueryBuilder('s');

        $expr = $q->expr()->andX(
            $q->expr()->eq('IDENTITY(s.contactclient)', (int) $contactClientId),
            $q->expr()->eq('s.type', ':type')
        );

        if ($fromDate) {
            $expr->add(
                $q->expr()->gte('s.dateAdded', ':fromDate')
            );
            $q->setParameter('fromDate', $fromDate);
        }
        if ($toDate) {
            $expr->add(
                $q->expr()->lte('s.dateAdded', ':toDate')
            );
            $q->setParameter('toDate', $toDate);
        }

        $q->where($expr)
            ->setParameter('type', $type);

        return $q->getQuery()->getArrayResult();
    }
211968
protected function getVisitsViewsPageDepth($days = 30, $pages = 5)
    {
        list($startDate, $endDate) = $this->calculateDays($days);

        $this->getVisitsViewsPageDepthForPeriod($startDate, $endDate, $pages);
    }
676232
public function matchAppointment(\Gems_Agenda_Appointment $appointment)
    {
        foreach ($this->_subFilters as $filterObject) {
            if ($filterObject instanceof AppointmentFilterInterface) {
                if ($filterObject->matchAppointment($appointment)) {
                    return true;
                }
            }
        }
        return false;
    }
876421
public function migrateExpiredJobs($from, $to)
	{
		$jobs = $this->getExpiredJobs($from, $time = $this->getTime());

		if (count($jobs) > 0)
		{
			$this->removeExpiredJobs($from, $time);

			call_user_func_array(array($this->redis, 'rpush'), array_merge(array($to), $jobs));
		}
	}
1217501
public function deleteByRange($from, $to)
    {
        DB::beginTransaction();
        try {
            $from = $from . ' 00:00:00';
            $to   = $to . ' 23:59:59';
            $logs = Logs::whereBetween('created_at', [$from, $to]);
            $logs->delete();
        } catch (Exception $ex) {
            Log::alert($ex);
            DB::rollback();
            return false;
        }
        DB::commit();
        return true;
    }
637915
static public function daysBetweenDates(string $date1, string $date2):? int
    {
        // If input dates have datetime 'Y-m-d X' format, take only the date part
        list($d1) = array_pad(explode(' ', $date1), 1, 0);
        list($d2) = array_pad(explode(' ', $date2), 1, 0);

        if (!self::checkDate($d1) || !self::checkDate($d2)) {
            return null;
        }

        if (!($dates = self::splitDates($d1, $d2))) {
            return null;
        }

        return (count($dates) - 1);
    }
1106021
public static function subDays($date, $days)
    {
        $d = self::formatDate($date);
        $d = date_parse($d);
        $d = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'] - $days, $d['year']);
        return self::formatDate($d);
    }
750558
private function checkDateIsValid($date, $canBeNull = false)
    {
        if ($date === null
            && $canBeNull
        ) {
            return;
        }

        Date::factory($date);
    }
1192241
public boolean contains(final Date date) {
        
        ArgUtils.notNull(date, "date");
        
        if(startDate == null) {
            return endDate.compareTo(date) >= 0;
            
        } else if(endDate == null) {
            return startDate.compareTo(date) <= 0;
            
        } else {
            return (endDate.compareTo(date) >= 0) && (startDate.compareTo(date) <= 0);
        }
        
    }
465731
public boolean contains(final Date date) {
        ArgUtils.notNull(date, "date");
        
        for(EraPeriod period : periods) {
            if(period.contains(date)) {
                return true;
            }
        }
        
        return false;
    }
832214
public function isApprovedNow($when = null)
    {
        if (!$this->isApproved()) {
            return false;
        }
        $start = $this->getPublishDate();
        $end = $this->getPublishEndDate();
        if (!$start && !$end) {
            return true;
        }
        $dh = Facade::getFacadeApplication()->make('date');
        if ($when) {
            $when = $dh->toDB($when);
        }
        if (!$when) {
            $when = $dh->getOverridableNow();
        }
        if ($start && $start > $when) {
            return false;
        }
        if ($end && $end < $when) {
            return false;
        }

        return true;
    }
729113
public function isDateOlderThanDays(\DateTime $date, $days)
    {
        $now = new \DateTime();

        return ($now->diff($date)
                    ->format('%a') >= $days);
    }
553057
public function getReportQuery($siteId, $fromDate, $toDate, $filter, $limit = null)
    {
        $siteList = [];
        $filter   = strtolower($filter);

        if (empty($fromDate)) {
            $fromDate = (new DateTime('first day of the year'))->format('Y-m-d');
        }

        if (empty($toDate)) {
            $toDate = (new DateTime('last day of this month'))->format('Y-m-d');
        }

        $builder = $this->getEntityManager()->createQuerybuilder();
        $query   = $builder->select(
            [
                '(e.popularity) total',
                'DATE(e.rankedAt) regDay',
                's.domain domain',
                '1 valid',
                'e.rankedAt createdAt',
            ]
        )->from($this->getEntity(), 'e')
            ->innerJoin('e.site', 's')
            ->where('e.rankedAt >= :start')
            ->andWhere('e.rankedAt <= :end')
            //->andWhere('s.siteType = :siteType')
            ->addOrderBy('e.rankedAt')
            ->addOrderBy('e.popularity')
            ->addGroupBy('e.site')
            ->setParameters(
                [
                    ':start'    => $fromDate,
                    ':end'      => $toDate,
                   // ':siteType' => 1,
                ]
            );

        if ($siteId) {
            $siteList = array_filter(array_unique(array_merge($siteList, (array)$siteId)));
        } elseif ($limit) {
            $subQueryBuilder = $builder = $this->getEntityManager()->createQuerybuilder();
            $subQuery        = $subQueryBuilder->select('f.id, s.id site_id')
                ->from($this->getEntity(), 'f')
                ->innerJoin('f.site', 's')
                ->groupBy('s.id')
                ->orderBy('f.popularity', 'ASC')
                ->setMaxResults($limit);

            foreach ($subQuery->getQuery()->getArrayResult() as $item) {
                $siteList[] = $item['site_id'];
            }
        }

        if ($siteList) {
            $query->andWhere($builder->expr()->in('s.id', $siteList));
        }
        switch ($filter) {
            case 'year':
                $query->addSelect('YEAR(e.rankedAt) regYear')
                    ->addGroupBy('regYear');
                break;
            case 'month':
                $query->addSelect('Month(e.rankedAt) regMonth')
                    ->addGroupBy('regMonth');
                break;
            case 'week':
                $query->addSelect('WEEK(e.rankedAt) regWeek')
                    ->addGroupBy('regWeek');
                break;
            case 'hour':
                $query->addSelect('HOUR(e.rankedAt) regHour')
                    ->addGroupBy('regHour');
                break;
            case 'day':
            default:
                $query->addGroupBy('regDay');
        }

        return $query->getQuery()->getArrayResult();
    }