@param DateTime $date

@return null|VATPeriod
541618
public function getPeriod($date)
    {
        $resultPeriod = null;

        for ($i = count($this->periods) - 1; $i >= 0; $i--) {
            $period = $this->periods[$i];

            if ($period->getEffectiveFrom() <= $date) {
                $resultPeriod = $period;
            }
        }

        return $resultPeriod;
    }
1338813
private static function cast(Date $date = null)
	{
		if (!is_null($date))
		{
			$date = new DateTime($date);
		}

		return $date;
	}
1095704
public function date($date, $format = null)
	{
		$datetime = DateTimeUtil::getDateTime($date);
        if (empty($format)) {
			$format = $this->cfg['date_format'];
		}
		if ($format == 'rel') {
			$date = DateTimeUtil::getRelTime($datetime);
		} else {
			$date = $datetime->format($format);
		}
		return $date;
	}
1195822
public static function get(UTCDateTime $date): DateTime
    {
        $date = $date->toDateTime();
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
1208176
public static function dateTimePHP2Sql($date)
	{
		// 31/01/2016 20:20:00 --> 2016-01-31 00:00
		if ($date == null) {
			return DaoOne::$dateEpoch;
		}
		if ($date->format("u")!='000000') {
			return $date->format('Y-m-d H:i:s.u');
		} else {
			return $date->format('Y-m-d H:i:s');
		}

	}
192411
protected function getFormatedDateTime( Date $date = null, Time $time = null ) {
		$timestamp = null;
		if($date && $time) {
			$timestamp = strtotime($date . ' ' . $time);
		}
		else {
			$timestamp = time();
		}
		return gmdate('Ymd\THis\Z', $timestamp);
	}
480422
public function getDatetimeObject($datetime = null)
    {
        if ($datetime instanceof DateTimeInterface) {
            return $datetime;
        }

        if (is_integer($datetime)) {
            $datetime = date('Y-m-d H:i:s', $datetime);
        }

        return new DateTime($datetime);
    }
411810
protected static function convertDateTime($date)
    {
        if (!$date) {
            return;
        }

        $date = new \DateTime($date);
        $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));

        return $date->format(\DateTime::ISO8601);
    }
874346
protected function getValidDateObject($date)
    {
        if (empty($date)) {
            return null;
        }
        if (is_string($date)) {
            return new Carbon($date);
        }

        return $date;
    }
1247210
public function setDate(\DateTime $date): self
    {
        $date->setTimezone(new \DateTimeZone('UTC'));
        $this->header->set('Date', $date->format('D, d M Y H:i:s') . ' GMT');

        return $this;
    }
1308739
public function findByDate(\DateTime $date = null)
    {
        $qb = $this->createQueryBuilder('p')
            ->where('p.date LIKE :date')
            ->addOrderBy('p.date', 'DESC')
            ->addOrderBy('p.id', 'DESC')
            ->setParameter('date', $date->format('Y-m-d').'%');

        return $qb->getQuery()->getResult();
    }
179025
public static function parseForumDate(string $date): ?\DateTimeImmutable
    {
        if (!preg_match('/\d{4}/', $date)) {
            $date .= ', '.date('Y');
        }

        return self::parseDate($date);
    }
649239
public static function inFuture($date, $time = null)
    {
        if (is_null($time)) {
            $time = self::time();
        }
        if (!is_int($date)) {
            $date = self::strtotime($date);
        }

        return $time < $date;
    }
163346
protected static function prepareDate($date)
    {
        if (null === $date) {
            return null;
        }
        if ($date instanceof DateTime) {
            return static::timeToString($date->getTimestamp());
        } elseif (is_numeric($date)) {
            return static::timeToString($date);
        } elseif (is_array($date)) {
            return @$date['date'];
        } elseif (self::hasTimestamp($date)) {
            return static::timeToString($date->getTimestamp());
        } elseif (is_string($date)) {
            return false !== strtotime($date) ? $date : null;
        }

        return null;
    }
946131
public static function shortDate($date)
    {
        if (self::isDate($date)) {
            $str = self::dateTimeToTimeStamp($date);
            $string = date("d.m.Y", $str);
            return $string;
        } else {
            return null;
        }
    }
785248
public function isDue(DateTime $date = null)
    {
        // The execution time is being defaulted if not defined
        if (! $this->executionTime) {
            $this->at('* * * * *');
        }

        $date = $date !== null ? $date : $this->creationTime;

        if ($this->executionYear && $this->executionYear !== $date->format('Y')) {
            return false;
        }

        return $this->executionTime->isDue($date);
    }
886822
public function get(string $date = null) : array
    {
        if ($date === null) {
            $date = \date('Y-m-d');
        }

        return [
            'queued' => $this->queue->count(),
            'pass' => $this->queue->getStatsByType($date, 'pass'),
            'fail' => $this->queue->getStatsByType($date, 'fail'),
            'retry' => $this->queue->getStatsByType($date, 'retry'),
            'cancel' => $this->queue->getStatsByType($date, 'cancel')
        ];
    }