Add an the given $interval to $this->time and return a reference to the original object
If the argument $format is not given it returns the sql format 'Y-m-d H:i:s'

@param string $interval
@param string $format optional
@return void
970735
public function add(string $interval, $format = ''){
    $tmp  = new \bbn\time($this->format());
    $tmp->time->add($this->get_interval($interval));
    return $tmp->format($format);
  }
1185995
public function setFormat(FormatInterface $format)
    {
        $this->formatId = $format->getName();

        return parent::setFormat($format);
    }
320660
public function push(Period $interval, Period ...$intervals): void
    {
        $this->intervals = array_merge($this->intervals, [$interval], $intervals);
    }
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;
    }
929780
public function setFormat($format)
    {
        $this->format = $format;
        if ($this->format === self::FORMAT_UNIX) {
            $this->newline = "\n";
        } elseif ($this->format === self::FORMAT_DOS) {
            $this->newline = "\r\n";
        }
    }
605471
public static function createFromFormat($time, $format = null)
    {
        if (self::isNull($format)) {
            $format = self::$defaultFormat;
        }

        try {
            $date = \DateTime::createFromFormat($format, $time);
            if (!$date) {
                throw new DateTimeObjectException(DateTimeObjectException::MSG_UNABLE_TO_CREATE_FROM_FORMAT);
            }
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_UNABLE_TO_CREATE_FROM_FORMAT);
        }

        try {
            $dt = new DateTimeObject();
            $dt->setTimestamp($date->getTimestamp());
            $dt->setFormat($format);
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_UNABLE_TO_CREATE_FROM_FORMAT);
        }

        return $dt;
    }
776947
public function add($date, $interval)
    {
        if (!$interval instanceof \DateInterval) {
            $interval = new \DateInterval($interval);
        }
        $result = clone $date;
        return $result->add($interval);
    }
1095463
public function setFormat($format = false)
    {
        if(!$format)
        {
            $format = \Ginger\System\Parameters::$format;
        }
        $this->format   = $format;

        if(!isset($this->allowedFormats[$this->format]))
        {
            $this->format = $this->defaultFormat;
        }
    }
19951
public function format($format = null)
    {
        if (func_num_args()) {
            return parent::format($format);
        }
        if ($this->_format === null) {
            $this->negotiate();
        }
        return $this->_format;
    }
205736
public static function setStringFormat(string $format)
    {
        switch ($format) {
            case 'raw':
                self::$format = 'raw';
                break;
            case 'basic':
                self::$format = 'basic';
                break;
            case 'full':
            default:
                self::$format = 'full';
                break;
        }
    }
839036
final public function format($format)
    {
        if(is_null($this->value)) {
            return null;
        } else {
            return $this->value->format($format);
        }
    }
13258
public function getOffsetDates($format, $interval = 30)
    {
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string')
            //argument 2 must be an integer
            ->test(2, 'int');

        $dates = array();
        $interval *= 60;

        for ($i=-12*3600; $i <= (12*3600); $i+=$interval) {
            $time = $this->time + $i;
            $dates[$i] = date($format, $time);
        }

        return $dates;
    }
223149
public function format($format = [])
    {
        $this->tempInterval = $this->interval;
        $hours = $this->getHours(PHP_ROUND_HALF_DOWN);
        $this->interval = $this->tempInterval % (1000 * 60 * 60);
        $minutes = $this->getMinutes(PHP_ROUND_HALF_DOWN);
        $this->interval = $this->tempInterval % (1000 * 60);
        $seconds = $this->getSeconds(PHP_ROUND_HALF_DOWN);
        $this->interval = $this->tempInterval;
        if (is_string($format)) {
            $result = strtr($format, [
            '{hours}'  => $hours,
            '{minutes}' => $minutes,
            '{seconds}' => $seconds,
        ]);
        } else {
            if ($seconds <= 0) {
                $format['{seconds}'] = '';
            }
            if ($minutes <= 0) {
                $format['{minutes}'] = '';
            }
            if ($hours <= 0) {
                $format['{hours}'] = '';
            }
            $format['{seconds}'] = strtr($format['{seconds}'], ['{seconds}' => $seconds]);
            $format['{minutes}'] = strtr($format['{minutes}'], ['{minutes}' => $minutes]);
            $format['{hours}'] = strtr($format['{hours}'], ['{hours}' => $hours]);
            $result = trim(strtr($format['template'], $format));
        }

        $result = $this->fixSingulars($result);

        return $result;
    }
1312634
public function format($format = null)
    {
        if (empty($format)) {
            $format = $this->defaultFormat;
        }
        return $this->formatDatetimeObject($format);
    }
485394
private function calc($value, $format)
	{
		$value = intval($value);
		$spec = sprintf($format, abs($value));

		return $value > 0 ? $this->add(new DateInterval($spec)) : $this->sub(new DateInterval($spec));
	}
681352
public static function DateFormat($format, $date = null)
  {
    if (!empty($date) && !is_int($date)) {
      $date = strtotime($date);
    }

    return strftime($format, $date ?: time());
  }
953343
public function format($format)
    {
        $function = $this->localFormatFunction ?: static::$formatFunction;

        if (!$function) {
            return $this->rawFormat($format);
        }

        if (is_string($function) && method_exists($this, $function)) {
            $function = [$this, $function];
        }

        return $function(...func_get_args());
    }