@return int

return -1 : if schedule is not set
return x >= 0 : if schedule is set
775458
public function getScheduleDelay()
    {
        $value = $this->getSchedule();
        if (null === $value) {
            return -1;
        }

        $object = CronExpression::factory($value);

        $format = 'Y-m-d H:i:s';
        $timeFirst = strtotime($object->getNextRunDate()->format($format));
        $timeSecond = strtotime(date($format));

        return (int) $timeFirst - $timeSecond;
    }
1230979
protected function _initAction()
    {
        if (!Mage::getStoreConfigFlag('system/cron/enable')) {
            $this->_getSession()->addNotice($this->__('Scheduler is disabled in configuration (system/cron/enable). No schedules will be executed.'));
        } else {
            $this->checkHeartbeat();
        }

        // check configuration
        if (Mage::getStoreConfig('system/cron/schedule_generate_every') > Mage::getStoreConfig('system/cron/schedule_ahead_for')) {
            $this->_getSession()->addError($this->__('Configuration problem. "Generate Schedules Every" is higher than "Schedule Ahead for". Please check your <a href="%s">configuration settings</a>.', $this->getUrl('adminhtml/system_config/edit', array('section' => 'system')) . '#system_cron'));
        }

        // Check the cron is being run as the configured user and whether or not to show the message
        $this->_checkCronUser();

        return $this->loadLayout()
            ->_setActiveMenu('system')
            ->_addBreadcrumb($this->__('System'), $this->__('System'))
            ->_addBreadcrumb($this->__('Scheduler'), $this->__('Scheduler'))
            ->_title($this->__('System'))
            ->_title($this->__('Scheduler'));
    }
796622
public static function getPeriodToFrequency()
    {
        return array(
            Schedule::PERIOD_NEVER => Piwik::translate('General_Never'),
            Schedule::PERIOD_DAY   => Piwik::translate('General_Daily'),
            Schedule::PERIOD_WEEK  => Piwik::translate('General_Weekly'),
            Schedule::PERIOD_MONTH => Piwik::translate('General_Monthly'),
        );
    }
302456
private function needsSchedulingForDirtyCheck()
    {
        return $this->owner && $this->dm && $this->mapping->isOwningSide
            && $this->dm->getClassMetadata(get_class($this->owner))->isChangeTrackingNotify();
    }
522382
public function getReleaseTime() : int
    {
        $query = 'SELECT release_time FROM info LIMIT 1';

        $releaseTime = 0;
        foreach ($this->getAdapter()->query($query) as $row) {
            $releaseTime = (int)$row['release_time'];
        }

        return $releaseTime;
    }
763789
private function checkMonthEdge()
    {
        if(!$this->erro) {
            asort($this->position);
            $this->position = array_keys($this->position);

            if ((isset($this->position[0]) && $this->position[0] === "mes") || (isset($this->position[2]) && $this->position[2] === "mes")) {
                $n = $this->position[1];
                if (!$this->certeza['mes'] && !$this->certeza[$n] && $this->data[$n] < 13 && $this->data[$n] > 0) {
                    $temp = $this->data['mes'];
                    $this->data['mes'] = $this->data[$n];
                    $this->data[$n] = $temp;
                }
            }
        }
    }
312068
protected function calculatePollTimeout()
    {
        if ($this->getScheduler()->isEmpty()) {
            return 60000;
        }

        $nextSchedule = $this->getScheduler()->top();
        $nextTime = $nextSchedule->getNextRunDate();

        $timeout = $nextTime-time();
        if ($timeout > 60) {
            $timeout = 60;
        }
        
        if ($timeout < 0) {
            return 0;
        }

        return $timeout*1000;
    }
446628
protected function getNextAtTimestamp(): ?int
    {
        $at = time();

        $items = $this->client->zrangebyscore(self::AT_QUEUE_NAME, '-inf', $at, ['limit', 0, 1]);

        if (empty($items)) {
            return null;
        }

        return (int)$items[0];
    }
720016
public function getOrdinal()
	{
		$ordinal = array_search($this->value, array_values(static::toArray()));

		return $ordinal !== false ? $ordinal : -1;
	}
514574
function nextValidStart(schedules) {
    var latest;
    for(var i = 0, len = schedules.length; i < len; i++) {
      var end = schedules[i].range[1];
      latest = !latest || end < latest ? end : latest;
    }

    return latest;
  }
239288
private function get_slot() {
		for ($i = 0; $i < $this->max_processes; $i++) {
			if ($this->processes[$i] == -1) {
				return $i;
			}
		}
		return -1;
	}
1316393
public Scheduler getScheduler() {
    if (scheduler == null) {
      scheduler = new Scheduler();
      scheduler.setDaemon(true);
      scheduler.start();
    }
    return scheduler;
  }
368520
protected final long nextScheduledTaskNano() {
        Queue<ScheduledFutureTask<?>> scheduledTaskQueue = this.scheduledTaskQueue;
        ScheduledFutureTask<?> scheduledTask = scheduledTaskQueue == null ? null : scheduledTaskQueue.peek();
        if (scheduledTask == null) {
            return -1;
        }
        return Math.max(0, scheduledTask.deadlineNanos() - nanoTime());
    }
351573
public function compareTo(MonthDay $that) : int
    {
        if ($this->month < $that->month) {
            return -1;
        }
        if ($this->month > $that->month) {
            return 1;
        }
        if ($this->day < $that->day) {
            return -1;
        }
        if ($this->day > $that->day) {
            return 1;
        }

        return 0;
    }
60721
public function nextRun()
    {
        if (empty(getInstance()->scheduler->IOCallBack[$this->requestId])) {
            return true;
        }

        foreach (getInstance()->scheduler->IOCallBack[$this->requestId] as $k => $coroutine) {
            if ($coroutine->ioBack && !empty(getInstance()->scheduler->taskMap[$this->requestId])) {
                unset(getInstance()->scheduler->IOCallBack[$this->requestId][$k]);
                getInstance()->scheduler->schedule(getInstance()->scheduler->taskMap[$this->requestId]);
            } else {
                break;
            }
        }

        return true;
    }
1014473
private function getWaitInterval()
    {
        if ($this->queuer instanceof QueueInterface) {
            $waitTime = $this->iterationsWithOutTask * self::WAIT_INTERVAL;

            return min($waitTime, self::MAX_SLEEPING_TIME_FOR_DEDICATED_QUEUE);
        } else if ($this->queuer instanceof QueueDispatcherInterface) {
            return (int) $this->queuer->getWaitTime();
        } else {
            return self::WAIT_INTERVAL;
        }
    }
536961
public function daysInMonth(): int
    {
        try {
            return $this->calendar->daysInMonth($this->year, $this->month);
        } catch (InvalidArgumentException $ex) {
            // calendar.php calls this with "DD MMM" dates, for which we cannot calculate
            // the length of a month. Should we validate this before calling this function?
            return 0;
        }
    }