Gets the date offset (amount by which any date values should be
adjusted) for the current restore.

@param string $restoreid Restore identifier
@return int Date offset (0 if none)
@throws coding_exception If not in a restore (or not in that restore)
331490
public static function get_restore_date_offset($restoreid) {
        if (!self::$restoreinfo) {
            throw new coding_exception('Only valid during restore');
        }
        if (self::$restoreinfo['restoreid'] !== $restoreid) {
            throw new coding_exception('Data not available for that restore id');
        }
        return self::$restoreinfo['dateoffset'];
    }
574570
public function setParameter( $parameter, $value, $restorePoint = self::PREVIOUS, $type = self::SESSION )
    {

        if (!is_scalar($value)) {
            throw new BadTypeException($value, 'scalar');
        }

        self::isParameterAllowed( $parameter );
        if( !in_array( $type, array( self::SESSION, self::LOCAL ) ) ) {
            throw new \InvalidArgumentException("WTF!");
        }

        if( $restorePoint and !is_scalar($restorePoint) ) {
            throw new \InvalidArgumentException( "RestorePoint has to be a scalar.");
        }

        // manage previous and original stores
        $currentValue = $this->getParameter( $parameter );

        if( !isset( $this->parameterStore[$parameter][self::ORIGINAL] ) ) {
            $this->parameterStore[$parameter][self::ORIGINAL] = $currentValue;
        }

        $this->parameterStore[$parameter][self::PREVIOUS] = $currentValue;

        // we can't quote a parameter value so regex
        /*
        if( preg_match_all('/[^a-zA-Z0-9_]/', $value, $matches ) ) {
            $badChars = implode('', $matches[0]);
            throw new \Exception( "We can't quote parameter values. Bad characters `{$badChars}`" );
        }
         */

        // bool
        if( $value === true ) {
            $value = 'true';
        } elseif( $value === false ) {
            $value = 'false';
        }

        // parameters
        if( $restorePoint !== self::PREVIOUS ) {
            $this->parameterStore[$parameter][$restorePoint] = $value;
        }

        $value = $this->query( new Raw("SET {$parameter} TO {$value}") );

        return $this;

    }
1277228
public function getMinStartTime(string $listID = ''): ?int
    {
        $list = $this->getListData($listID);
        if (empty($list)) {
            return null;
        }
        $minStartTime = null;
        $hasTaskWithoutStartDate = false;
        foreach ($list as $taskListData) {
            if ($taskListData[0] === 1) { // version check
                if ($taskListData[1] === null) { // does not have start time
                    $hasTaskWithoutStartDate = true;
                } else { // has start time
                    if ($minStartTime === null || $taskListData[1] < $minStartTime) {
                        $minStartTime = $taskListData[1];
                    }
                }
            }
        }
        $currentTime = time();
        if ($minStartTime === null) {
            return $currentTime;
        }
        if ($hasTaskWithoutStartDate) {
            return $minStartTime < $currentTime ? $minStartTime : $currentTime;
        } else {
            return $minStartTime;
        }
    }
1116034
private function expired($cacheId)
    {
        $item = $this->cachedItems[$cacheId];
        return (! $this->storage->exists($cacheId)) ||
               $this->timeUtil->expired($item->expiry);
    }
619834
public function readDate() {
            $dateref = $this->readU29();
            if (($dateref & 0x01) == 0) {
                $dateref = $dateref >> 1;
                if ($dateref>=count($this->storedObjects)) {
                    throw new Exception('Undefined date reference: ' . $dateref);
                    return false;
                }
                return $this->storedObjects[$dateref];
            }

            $timestamp = floor($this->stream->readDouble() / 1000);

            $dateTime = new DateTime('@' . $timestamp);
            
            $this->storedObjects[] = $dateTime;
            return $dateTime;
        }
1159245
public function getUpdatedAt() : ?int 
    {
        if ( ! $this->hasUpdatedAt()) {
            $this->setUpdatedAt($this->getDefaultUpdatedAt());
        }
        return $this->updatedAt;
    }
134917
public function lastInsertId(string $sequenceId = null): string
    {
        if ($sequenceId !== null) {
            return $this->connection()->lastInsertId($sequenceId);
        }

        return $this->connection()->lastInsertId();
    }
659621
public function get($oid, $preserveKeys = false) {
        if ($this->cache() && ( $rtn = $this->getCache()->load($oid) ) !== null) {
            return $rtn;
        }

        try {
            $this->_lastResult = $this->_session->get($oid, $preserveKeys);
        } catch (Exception $exc) {
            $this->close();
            throw new Exception("Erro '{$this->_session->getError()}' with execute GET OID ({$oid}): " . $exc->getMessage());
        }

        if ($this->_lastResult === false) {
            $this->close();
            throw new Exception('Could not perform walk for OID ' . $oid);
        }

        return $this->getCache()->save($oid, $this->parseSnmpValue($this->_lastResult));
    }
1128891
public function offsetGet($offset)
    {
        return isset($this->dates[$offset]) ? $this->dates[$offset] : null;
    }
1318115
public function setDateBack( $backdate )
	{
		if ( $backdate === $this->getDateBack() ) { return; }

		$this->_checkDateFormat($backdate);

		if ( $backdate !== null ) {
			$backdate = (string) $backdate;
		}

		$this->_values['backdate'] = $backdate;
		$this->setModified();
	}
863574
public function isOutdated(DataBackend $backend)
    {
        /*
         * The following code creates a sorted list with the release months (update month - $relaseThreshold)
         * and the current month. To build that threshold date simply pick the month before the current month from
         * that list.
         * 
         * Note that the second parameter of the date() calls is there on purpose. This allows
         * to mock time() for testing.
         */

        /*
         * The current month gets an increment of 0.5 for the case that the current month is a 
         * release month (e.g. the list will look (2, 2.5, 5, 8, 11)).
         */
        $currentMonth = date("n", time()) + 0.5;

        $monthList = array($currentMonth);
        foreach (self::$updateMonths as $month) {
            $releaseMonth = $month - self::$relaseThreshold;
            $monthList[] = $releaseMonth;

        }
        sort($monthList); // You have now something like (2, 2.5, 5, 8, 11).

        // Now add the cycle between the last and the first month(11, 2, 3.5, 5, 8, 11, 2).
        $monthList[] = self::$updateMonths[0] - self::$relaseThreshold; // this is acually not needed.
        array_unshift($monthList, self::$updateMonths[count(self::$updateMonths) - 1] - self::$relaseThreshold);
        
        $index = array_search($currentMonth, $monthList);
        assert($index > 0);
        $previousIndex = $index - 1;

        $thresholdMonth = $monthList[$previousIndex];

        // flip the year if the threshold was in the last year.
        $year = $thresholdMonth > $currentMonth ? date("Y", time()) - 1 : date("Y", time());

        $threshold = mktime(0, 0, 0, $thresholdMonth, 1, $year);
        
        return $backend->getLastUpdate() < $threshold;
    }
53710
public function getDate() : ?int 
    {
        if ( ! $this->hasDate()) {
            $this->setDate($this->getDefaultDate());
        }
        return $this->date;
    }
824141
public function getConfigurationRollbackComparison($rollbackID, $compareID=null)
    {

        $rollbackCompare = new \SimpleXMLElement('<get-rollback-information/>');

        $rollbackCompare->addChild('rollback', $rollbackID);

        if (!is_null($compareID)) {

            $rollbackCompare->addChild('compare', $compareID);

        }

        return $this->netConf()->sendRPC($rollbackCompare->asXML());

    }
310037
public function getLastVersionNumber($contentId)
    {
        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $query->expr->max($this->dbHandler->quoteColumn('version'))
        )->from(
            $this->dbHandler->quoteTable('ezcontentobject_version')
        )->where(
            $query->expr->eq(
                $this->dbHandler->quoteColumn('contentobject_id'),
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        return (int)$statement->fetchColumn();
    }
682775
public function get($cacheId)
    {
        $this->throwExceptionIfNotExists($cacheId);

        if ($this->expired($cacheId)) {
            return $this->getFromCacheable($cacheId);
        }

        return $this->getCachedItem($cacheId);
    }
689998
public function getCurrentMonthPeriod($organizationId = null)
  {
    if(empty($organizationId))
    {
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');
    }

    $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId);

    $Date = new Carbon('first day of this month');
    $Date2 = new Carbon('last day of this month');

    return $this->Period->periodByStardDateByEndDateByFiscalYearAndByOrganizationId($Date->format('Y-m-d'), $Date2->format('Y-m-d'), $fiscalYearId, $organizationId);
  }
154592
protected static function get_backup_ids_cached($restoreid, $itemname, $itemid) {
        global $DB;

        $key = "$itemid $itemname $restoreid";

        // If record exists in cache then return.
        if (isset(self::$backupidsexist[$key]) && isset(self::$backupidscache[$key])) {
            // Return a copy of cached data, to avoid any alterations in cached data.
            return clone self::$backupidscache[$key];
        }

        // Clean cache, if it's full.
        if (self::$backupidscachesize <= 0) {
            // Remove some records, to keep memory in limit.
            self::$backupidscache = array_slice(self::$backupidscache, self::$backupidsslice, null, true);
            self::$backupidscachesize = self::$backupidscachesize + self::$backupidsslice;
        }
        if (self::$backupidsexistsize <= 0) {
            self::$backupidsexist = array_slice(self::$backupidsexist, self::$backupidsslice, null, true);
            self::$backupidsexistsize = self::$backupidsexistsize + self::$backupidsslice;
        }

        // Retrive record from database.
        $record = array(
            'backupid' => $restoreid,
            'itemname' => $itemname,
            'itemid'   => $itemid
        );
        if ($dbrec = $DB->get_record('backup_ids_temp', $record)) {
            self::$backupidsexist[$key] = $dbrec->id;
            self::$backupidscache[$key] = $dbrec;
            self::$backupidscachesize--;
            self::$backupidsexistsize--;
            return $dbrec;
        } else {
            return false;
        }
    }