@param TimePoint $start
@param TimeInterval $interval
@param int $recurrences
@param int $options

@return TimePeriod
965426
public static function createWithRecurrences(TimePoint $start, TimeInterval $interval, $recurrences, $options = 0)
    {
        $cur = $start;
        if ($options & DatePeriod::EXCLUDE_START_DATE) {
            $recurrences = $recurrences + 1;
        }
        for ($i = 0; $i < $recurrences; $i++) {
            $cur = $cur->add($interval);
        }
        return new self($start, $interval, $cur, $options);
    }
1087617
final public static function recalculateInterval($interval)
    {
        try {
            $from = new \DateTimeImmutable();
            $to = $from->add($interval);
            $diff = $to->diff($from);
            foreach ($diff as $k => $v) {
                $interval->$k = $v;
            }

        } catch (\Exception $e) {
        }

        return $interval;
    }
986591
public static function sessionStart(array $options = null) {
		if (true === ($options === null ? @session_start() : @session_start($options))) return;
				
		$err = error_get_last();
		throw new HttpRuntimeException($err['message']);
	}
1239719
public function withIntervalInMonths($intervalInMonths)
    {
        $this->validateInterval($intervalInMonths);
        $this->interval = $intervalInMonths;
        $this->intervalUnit = IntervalUnit::MONTH;

        return $this;
    }
136692
public function withIntervalInDays($intervalInDays)
    {
        $this->validateInterval($intervalInDays);
        $this->interval = $intervalInDays;
        $this->intervalUnit = IntervalUnit::DAY;

        return $this;
    }
817359
protected static function intervalHasTime(DateInterval $interval)
    {
        // The array_key_exists and get_object_vars are used as a workaround to check microsecond support.
        // Both isset and property_exists will fail on PHP 7.0.14 - 7.0.21 due to the following bug:
        // https://bugs.php.net/bug.php?id=74852
        return $interval->h || $interval->i || $interval->s || array_key_exists('f', get_object_vars($interval)) && $interval->f;
    }
248895
public static function createIntervalFromSpec($interval_spec)
	{
		return	isset(static::$intervals[$interval_spec])
				?	static::$intervals[$interval_spec]
				:	static::$intervals[$interval_spec] = new \DateInterval($interval_spec);
	}
183247
public function setUpdateCheck($interval)
    {
        $validIntervals = [
            Checker::ALWAYS,
            Checker::DAILY,
            Checker::WEEKLY,
            Checker::MONTHLY,
            Checker::NEVER,
        ];

        if (!\in_array($interval, $validIntervals)) {
            throw new \InvalidArgumentException('invalid update check interval: ' . $interval);
        }

        $this->updateCheck = $interval;
    }
1218976
public function setInterval($planInterval)
    {
        $valid = ['weekly', 'monthly', 'yearly'];
        if (!in_array($planInterval, $valid)) {
            throw new InvalidRequestException('Interval must be one of '.implode(' / ', $valid));
        }

        return $this->setParameter('subscription_interval_unit', $planInterval);
    }
31603
public static MomentInterval from(ChronoInterval<Moment> interval) {

        if (interval instanceof MomentInterval) {
            return MomentInterval.class.cast(interval);
        } else {
            return new MomentInterval(interval.getStart(), interval.getEnd());
        }

    }
1154278
public static function startOf($interval, \DateTime $date = null) {
			$date = $date ?: new \DateTime();

			switch ($interval) {
				case self::INTERVAL_MINUTE:
					$date->setTime((int)$date->format('H'), (int)$date->format('i'), 0, 0);

					break;

				case self::INTVERAL_HOUR:
					$date->setTime((int)$date->format('H'), 0, 0, 0);

					break;

				case self::INTERVAL_DAY:
					$date->setTime(0, 0, 0, 0);

					break;

				case self::INTERVAL_WEEK:
					$date
						->sub(new \DateInterval('P' . (int)$date->format('w') . 'D'))
						->setTime(0, 0, 0, 0);

					break;

				case self::INTERVAL_MONTH:
					$date
						->sub(new \DateInterval('P' . ((int)$date->format('d') - 1) . 'D'))
						->setTime(0, 0, 0, 0);

					break;

				case self::INTERVAL_YEAR:
					$date
						->setTime(0, 0, 0, 0)
						->setDate((int)$date->format('Y'), 1, 1);

					break;

				default:
					throw new \InvalidArgumentException('$interval must be one of the INTERVAL_* class constants');
			}

			return $date;
		}
673081
protected function _getInterval($interval) {
		if ($interval !== null) {
			return $interval;
		} elseif (!empty($this->params['interval'])) {
			return $this->params['interval'];
		} else {
			return '1 day';
		}
	}
889113
protected function find_intervals($interval)
    {
        if ($interval instanceof RangeInterface) {
            $first = $interval->getStart();
            $last = $interval->getEnd();
        } else {
            $first = $interval;
            $last = null;
        }

        if (null === $last) {
            $result = $this->point_search($this->top_node, $first);
        } else {
            $result = array();
            foreach ($interval->iterable() as $j) {
                $result = array_merge($result, $this->find_intervals($j));
            }
        }

        return $result;
    }
1116568
public static long getPreviousIntervalStart(long time, int intervalInMinutes, int offsetInMinutes) {
		long interval = MINUTE_IN_MS * intervalInMinutes;
		long offset = calculateOffsetInMs(intervalInMinutes, offsetInMinutes);
		
		return (interval * ((time + LOCAL_UTC_OFFSET - offset) / (interval))) + offset - LOCAL_UTC_OFFSET;
	}
1299914
public static function generateDateIndices($format, $interval, $from_ts, $to_ts) {
        $fmt_arr = [];
        $escaped = false;

        foreach(str_split($format) as $chr) {
            switch($chr) {
            case '[':
                $escaped = true;
                break;
            case ']':
                $escaped = false;
                break;
            default:
                $fmt_arr[] = $escaped ? "\\$chr":$chr;
                break;
            }
        }
        $fmt_str = implode('', $fmt_arr);

        $ret = [];
        $current = new \DateTime("@$from_ts");
        $to = new \DateTime("@$to_ts");

        $interval_map = [
            'y' => 'year',
            'm' => 'month',
            'w' => 'week',
            'd' => 'day',
            'h' => 'hour',
        ];
        $interval_str = Util::get($interval_map, $interval, 'day');

        // Zero out the time component.
        $current->setTime($interval == 'h' ? $current->format('H'):0, 0);

        while ($current <= $to) {
            $ret[] = $current->format($fmt_str);
            $current = $current->modify("+1$interval_str");
        }

        return $ret;
    }
1171701
public static TimestampInterval from(ChronoInterval<PlainTimestamp> interval) {

        if (interval instanceof TimestampInterval) {
            return TimestampInterval.class.cast(interval);
        } else {
            return new TimestampInterval(interval.getStart(), interval.getEnd());
        }

    }
616634
public function compute(Intervals $firstInterval, Intervals $secondInterval): Intervals
    {
        $first  = $firstInterval->getArrayCopy();
        $second = $secondInterval->getArrayCopy();
        if (0 === count($second)) {
            return $firstInterval;
        }

        $count = count($second);
        while ($count > 0) {
            $intervalToExclude = \array_shift($second);

            $newIntervals = [];

            /** @var Interval $interval */
            foreach ($first as $interval) {
                $newIntervals = \array_merge($newIntervals, $interval->exclude($intervalToExclude)->getArrayCopy());
            }

            $first                   = $newIntervals;
            $count                   = count($second);
        }

        return new Intervals($first);
    }