@param \DateInterval $interval

@return string
429845
private static function dateIntervalToString(\DateInterval $interval)
    {

        // Reading all non-zero date parts.
        $date = array_filter([
            'Y' => $interval->y,
            'M' => $interval->m,
            'D' => $interval->d,
        ]);

        // Reading all non-zero time parts.
        $time = array_filter([
            'H' => $interval->h,
            'M' => $interval->i,
            'S' => $interval->s,
        ]);

        $specString = 'P';

        // Adding each part to the spec-string.
        foreach ($date as $key => $value) {
            $specString .= $value.$key;
        }
        if (count($time) > 0) {
            $specString .= 'T';
            foreach ($time as $key => $value) {
                $specString .= $value.$key;
            }
        }

        return $specString;
    }
795991
public function sub(/*\DateInterval*/ $interval) : \DateTime /*self invariant*/
    {
        // NB: Argument type hinting (\DateInterval $interval)
        // would provoke E_WARNING when cloning.
        // Catch 22: Specs say that native \DateTime method is type hinted,
        // but warning when cloning says it isn't.

        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }
        return parent::sub($interval);
    }
1085501
static function convertInterval(DateInterval $d) {
		$i = 0;
		$i += $d->s;
		$i += $d->i * self::MINUTE;
		$i += $d->h * self::HOUR;
		$i += $d->d * self::DAY;
		$i += $d->m * self::MONTH;
		$i += $d->y * self::YEAR;

		return $i;
	}
1268410
public function sub(DateInterval $interval)
	{
		return $this->modify(
			function (\DateTime $datetime) use ($interval)
			{
				$datetime->sub($interval->getDateInterval());
			}
		);
	}
11686
public function add(/*\DateInterval*/ $interval) : \DateTime /*self invariant*/
    {
        // NB: Argument type hinting (\DateInterval $interval)
        // would provoke E_WARNING when cloning.
        // Catch 22: Specs say that native \DateTime method is type hinted,
        // but warning when cloning says it isn't.

        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }
        return parent::add($interval);
    }
1280199
public static function instance(DateInterval $di)
    {
        if (self::wasCreatedFromDiff($di)) {
            throw new InvalidArgumentException('Can not instance a Interval object created from DateTime::diff().');
        }

        $instance = new static($di->y, $di->m, 0, $di->d, $di->h, $di->i, $di->s);
        $instance->invert = $di->invert;
        $instance->days = $di->days;

        return $instance;
    }
43334
public function toTime(Time $interval = null)
    {
        $secInDay = Time::days(1)->sec;
        $interval = $interval ? $interval->sec : $secInDay;

        return Time::sec(($this->deg / 360) * $interval);
    }
182298
public static function turnDateIntervalToSeconds(DateInterval $dateInterval)
    {
        return $dateInterval->y * 365 * 24 * 3600
            + $dateInterval->m * 30 * 24 * 3600
            + $dateInterval->d * 24 * 3600
            + $dateInterval->h * 3600
            + $dateInterval->i * 60
            + $dateInterval->s;
    }
673081
protected function _getInterval($interval) {
		if ($interval !== null) {
			return $interval;
		} elseif (!empty($this->params['interval'])) {
			return $this->params['interval'];
		} else {
			return '1 day';
		}
	}
1027827
final public static function intervalToSeconds($interval)
    {
        try {
            $start = new \DateTimeImmutable();
            $end = $start->add($interval);
            return $end->getTimestamp() - $start->getTimestamp();
        } catch (\Exception $e) {
            return 0;
        }

    }
212594
public static function modify($dateAsString, $interval, $format = self::DEFAULT_TIME_FORMAT)
    {
        $dateTime = new DateTime($dateAsString);
        return $dateTime->modify($interval)->format($format);
    }
583025
private function copy(\DateInterval $interval)
	{
		$copy = new \DateInterval($interval->format('P%yY%mM%dDT%hH%iM%sS'));
		$copy->invert = $interval->invert;

		return $copy;
	}
267195
public function findVisitPages(Range $interval): array
	{
		$result = [];
		$subQuery = 'SELECT '
			. '[url], '
			. 'DATE([inserted]) datefield, '
			. 'COUNT([uid]) num '
			. 'FROM %table '
			. 'WHERE DATE([inserted]) BETWEEN DATE(%dt) AND DATE(%dt) '
			. 'GROUP BY [url], [uid], ROUND(UNIX_TIMESTAMP([inserted]) / %i)';
		$rows = $this->connection->query('SELECT [datefield], [url], COUNT([num]) visits, SUM([num]) views FROM (' . $subQuery . ') sub GROUP BY [url]', $this->getTableName(), $interval->from, $interval->to, $this->minTimeBetweenVisits * 60);

		foreach ($rows as $row) {
			$data = new stdClass;
			$data->datefield = $row->datefield;
			$data->visits = $row->visits;
			$data->views = $row->views;

			$url = new Url($row->url);
			$data->page = substr($url->getPath(), 1) ?: '';
			if (!empty($url->query)) {
				$data->page .= '?' . $url->getQuery();
			}
			if (!empty($url->fragment)) {
				$data->page .= '#' . $url->getFragment();
			}
			$result[] = $data;
		}
		return $result;
	}
1100632
public function interval($interval = null)
    {
        if (is_null($interval)) {
            return (int) $this->interval;
        }

        $this->interval = (int) $interval;

        return $this;
    }
776947
public function add($date, $interval)
    {
        if (!$interval instanceof \DateInterval) {
            $interval = new \DateInterval($interval);
        }
        $result = clone $date;
        return $result->add($interval);
    }
304675
final public static function intervalToSpec($interval)
    {
        $interval = self::recalculateInterval($interval);

        $result = "P";
        if ($interval->y !== 0) {
            $result .= sprintf('%dY', $interval->y);
        }

        if ($interval->m !== 0) {
            $result .= sprintf('%dM', $interval->m);
        }

        if ($interval->d !== 0) {
            $result .= sprintf('%dD', $interval->d);
        }


        $timeMarkerSet = false;
        if ($interval->h !== 0) {
            if (!$timeMarkerSet) {
                $result .= 'T';
            }

            $result .= sprintf('%dH', $interval->h);
        }

        if ($interval->i !== 0) {
            if (!$timeMarkerSet) {
                $result .= 'T';
            }

            $result .= sprintf('%dM', $interval->i);
        }

        if ($interval->s !== 0) {
            if (!$timeMarkerSet) {
                $result .= 'T';
            }

            $result .= sprintf('%dS', $interval->s);
        }

        if ($result == 'P') {
            return "";
        }

        return $result;
    }
548975
protected function generateDateIntervalXML(DateInterval $dateInterval)
    {
        // Constructing XML structure
        $doc = new DOMDocument('1.0', 'utf-8');
        $root = $doc->createElement('adjustment');

        $year = $doc->createElement('year');
        $year->setAttribute('value', $dateInterval->format('%y'));
        $root->appendChild($year);
        unset($year);

        $month = $doc->createElement('month');
        $month->setAttribute('value', $dateInterval->format('%m'));
        $root->appendChild($month);
        unset($month);

        $day = $doc->createElement('day');
        $day->setAttribute('value', $dateInterval->format('%d'));
        $root->appendChild($day);
        unset($day);

        $hour = $doc->createElement('hour');
        $hour->setAttribute('value', $dateInterval->format('%h'));
        $root->appendChild($hour);
        unset($hour);

        $minute = $doc->createElement('minute');
        $minute->setAttribute('value', $dateInterval->format('%i'));
        $root->appendChild($minute);
        unset($minute);

        $second = $doc->createElement('second');
        $second->setAttribute('value', $dateInterval->format('%s'));
        $root->appendChild($second);
        unset($second);

        $doc->appendChild($root);

        return $doc->saveXML();
    }