DaysFromDuration
@param object $arg
@return Integer
509206
public static function DaysFromDuration( $arg )
	{
		if ( $arg instanceof Undefined )
			return Undefined::getValue();

		/**
		 * @var DurationValue $duration
		 */
		$duration = $arg;

		$days = $duration->getDays() * ( $duration->getInverted() ? -1 : 1 );
		return Integer::FromValue( $days );
	}
439203
public function count($arg = null)
    {
        if (is_null($arg)) {
            $arg = '*';
        }

        return $this->expr('count([count])')->setCustom('count', $this->bt($arg));
    }
34986
public static function YearFromDate( $arg )
	{
		if ( $arg instanceof Undefined )
		{
			return Undefined::getValue();
		}

		if ( ! $arg instanceof DateValue )
		{
			return Undefined::getValue();
		}

		/**
		 * @var DateValue $date
		 */
		$date = $arg;
		return $date->Value->format( "Y" ) * ( $date->S ? -1 : 1 );
	}
279460
public function getArgType($arg): int
    {
        switch (gettype($arg)) {
            case 'double':
                return SQLITE3_FLOAT;
            case 'integer':
                return SQLITE3_INTEGER;
            case 'boolean':
                return SQLITE3_INTEGER;
            case 'NULL':
                return SQLITE3_NULL;
            case 'string':
                return SQLITE3_TEXT;
            default:
                $msg  = vsprintf('Argument is of invalid type "%s"', [gettype($arg),]);
                throw new DbException($msg, DbException::WRONG_TYPE);
        }
    }
783392
private ZonedDateTime parseDateTime(MessageArg arg) {
    long instant = arg.asLong();
    ZoneId timeZone = arg.timeZone() != null ? arg.timeZone() : this.timeZone;
    return ZonedDateTime.ofInstant(Instant.ofEpochMilli(instant), timeZone);
  }
708901
public function getDays($total = false)
    {
        return ($total == true) ? $this->getInterval()->days : $this->getInterval()->d;
    }
1145940
public static function TimezoneFromTime( $arg )
	{
		if ( $arg instanceof Undefined )
		{
			return Undefined::getValue();
		}

		if ( ! $arg instanceof TimeValue )
		{
			return Undefined::getValue();
		}

		/**
		 * @var TimeValue $time
		 */
		$time = $arg;

		if ( $time->IsLocal )
		{
			return Undefined::getValue();
		}

		return $time->TimezoneToInterval();

		// $offset = $time->Value->getOffset();
		// $invert = $offset >= 0 ? "+" : "-";
		// $offset = abs( $offset );
		// $timezone = DayTimeDurationValue::Parse( "PT{$offset}S" );
		// $timezone->Value->invert = $invert;
        //
		// return $timezone;
	}
162827
public function restoreBackup($arg)
    {
        $backup = 'no';
        $web = 'no';
        $dns = 'no';
        $mail = 'no';
        $db = 'no';
        $cron = 'no';
        $udir = 'no';
        extract($arg, EXTR_OVERWRITE);

        return $this->send('v-schedule-user-restore', $this->userName, $backup, $web, $dns, $mail, $db,
            $cron, $udir);
    }
860997
public function daysBetween(Date $other) : int
    {
        return $this->dateTime->diff($other->dateTime, true)->days;
    }
1061811
public static function AdjustTimeToTimezone( $arg )
	{
		if ( $arg instanceof Undefined )
		{
			return Undefined::getValue();
		}

		/**
		 * @var TimeValue $time
		 */
		$time = $arg;
		// if ( $time->IsLocal ) return $time;

		$dt = clone $time->Value;
		$dtz = new \DateTimeZone( date_default_timezone_get() );
		$dt->setTimezone( $dtz );
		$dateTime = new TimeValue( $dt );
		$dateTime->IsLocal = false;
		return $dateTime;
	}
1358337
function remove($args)
    {
        $cache  = $this->get_cache();
        $status = $cache->remove($args['id']);

        $args['status'] = true;

        return $args;
    }
830805
function timeAgo($date)
    {

        if (empty($date)) {

            return "No date provided";
        }

        $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");

        $lengths = array("60", "60", "24", "7", "4.35", "12", "10");

        $now = time();

        $unix_date = strtotime($date);

        // check validity of date

        if (empty($unix_date)) {

            return "Bad date";
        }

        // is it future date or past date

        if ($now > $unix_date) {

            $difference = $now - $unix_date;

            $tense = "ago";
        } else {

            $difference = $unix_date - $now;
            $tense = "from now";
        }

        for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {

            $difference /= $lengths[$j];
        }

        $difference = round($difference);

        if ($difference != 1) {

            $periods[$j] .= "s";
        }

        return "$difference $periods[$j] {$tense}";
    }
1008120
public static function monthize($days)
    {
        $now = new \DateTime();
        $end = new \DateTime();

        $duration = new \DateInterval("P{$days}D");

        $diff = $end->add($duration)->diff($now);

        // handle years
        if ($diff->y > 0) {
            $diff->m += 12 * $diff->y;
        }

        return $diff->m;
    }
182625
public function days()
    {
        if (!isset($this->days)) {
            $clonedStart = clone $this->weekStart;
            $this->days = array();
            for ($i = 0; $i < 7; $i ++) {
                $thisDay = new Day($clonedStart);

                if (
                    $this->containingMonth
                    && $this->containingMonth->firstDay()->format('m') != $clonedStart->format('m')
                ) {
                    $thisDay->setIsOverflow(true);
                }

                $this->days[] = $thisDay;
                $clonedStart->modify('+1 day');
            }
        }
        return $this->days;
    }
64772
public static function findCommandLong($arg) {
		foreach (self::$commands as $command => $commandOptions) {
			if (($commandOptions["commandLong"] == $arg) || ($commandOptions["commandShort"] == $arg)) {
				return $command;
			}
		}
		return false;
	}
141066
public function subtractDays($days)
    {
        $days = (int) $days;
        $days = -$days;
        return $this->addDays($days);
    }
1209263
public function handleAdd(Args $args)
    {
        $flags = $args->isOptionSet('force')
            ? RepositoryManager::OVERRIDE | RepositoryManager::IGNORE_FILE_NOT_FOUND
            : 0;
        $repositoryPath = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
        $pathReferences = $args->getArgument('file');

        $this->repoManager->addRootPathMapping(new PathMapping($repositoryPath, $pathReferences), $flags);

        return 0;
    }