@param TimePoint $date

@return DateTime
170894
private function timePointToDateTime(TimePoint $date)
    {
        $parserFormat = '@^(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)$@';
        $parsableFormat = 'Y-n-j-G-i-s-u';

        $tz = new DateTimeZone('UTC');
        preg_match($parserFormat, $date->format($parsableFormat, 'UTC'), $t);

        $format = sprintf(
            '%04d-%02d-%02d %02d:%02d:%02d.%06d',
            $t[1],
            $t[2],
            $t[3],
            $t[4],
            $t[5],
            $t[6],
            $t[7]
        );

        return new DateTime($format, $tz);
    }
939675
public static function getUtcDateTime( BaseDateTime $date )
    {
        $newDate = new BaseDateTime( );
        $newDate->setTimestamp( $date->getTimestamp() );
        $newDate->setTimezone( new DateTimeZone( 'UTC' ) );
        
        return $newDate;
    }
1328369
public function getUpdatedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->hasUpdatedAt()) {
            return null;
        }

        if ($timezone === null) {
            $timezone = 'UTC';
        }

        return new DateTime($this->getUpdatedAt(), new DateTimeZone($timezone));
    }
762189
public static function date($date){

		$Date = static::_utcZeroDateTime($date);

		if($Date === null){

			return $date;
		}

		return $Date->format('Y-m-d');
	}
1287163
public static function tokensExpireIn(DateTimeInterface $date = null)
    {
        if (is_null($date)) {
            return static::$tokensExpireAt
                            ? Carbon::now()->diff(static::$tokensExpireAt)
                            : new DateInterval('P1Y');
        }

        static::$tokensExpireAt = $date;

        return new static;
    }
1195822
public static function get(UTCDateTime $date): DateTime
    {
        $date = $date->toDateTime();
        $date->setTimezone(new DateTimeZone(date_default_timezone_get()));

        return $date;
    }
1035940
public function getCreatedAtDatetime(string $timezone = null): ?DateTime
    {
    	if ($this->created_at === null) {
    		return null;
	    }

        return new DateTime($this->created_at, new DateTimeZone($timezone ?? 'UTC'));
    }
1357386
public static function strtotime($date, $timezone = null)
    {
        $date   = self::clean_datestr($date);
        $tzname = $timezone ? ' ' . $timezone->getName() : '';

        // unix timestamp
        if (is_numeric($date)) {
            return (int) $date;
        }

        // It can be very slow when provided string is not a date and very long
        if (strlen($date) > 128) {
            $date = substr($date, 0, 128);
        }

        // if date parsing fails, we have a date in non-rfc format.
        // remove token from the end and try again
        while (($ts = @strtotime($date . $tzname)) === false || $ts < 0) {
            if (($pos = strrpos($date, ' ')) === false) {
                break;
            }

            $date = rtrim(substr($date, 0, $pos));
        }

        return (int) $ts;
    }
183710
public static function parseDateMDYReadable(string $date): ?\DateTimeImmutable
    {
        $date = str_replace('  ', ' ', $date);

        if (preg_match('~[a-zA-z]+ \d+, \d{4}~', $date)) {
            return new \DateTimeImmutable($date, new \DateTimeZone('UTC'));
        }

        return null;
    }
49837
public function setTimeZone($timezone)
	{
		$this->timezone = ($timezone instanceof \DateTimeZone)
			? $timezone
			: new \DateTimeZone($timezone);

		return $this;
	}
756541
public function diff(TimePoint $timepoint)
    {
        $interval = $this->date->diff($timepoint->date);
        $intervalSpec = $this->dateIntervalToIntervalSpec($interval);

        return new TimeInterval($intervalSpec);
    }
219998
private function parse($date, $timezone = null)
    {
        if (!($date instanceof \DateTime)) {
            if (false === strtotime($date)) {
                throw new \Exception('Invalid date not parsed.');
            }

            if (!$timezone) {
                $timezone = $this->timezoneSource;
            }

            $date = new \DateTime($date, new \DateTimeZone($timezone));
        }

        return $date;
    }
533204
public function data(TimePoint $now = null)
    {
        if ($now && $this->isExpired($now)) {
            return null;
        }

        return $this->data;
    }
1204307
public static function fromDate(\DateTime $date)
    {
        return new self($date->format('H'), $date->format('i'), $date->format('s'));
    }
618717
public static function parseDateMDY(?string $date): ?\DateTimeImmutable
    {
        if ($date === '-' || $date === null) {
            return null;
        }

        $dateArray = explode('-', $date);

        if ($dateArray[0] === '??' && $dateArray[1] === '??' && $dateArray[2] === date('y')) {
            return null;
        }

        $date = str_replace('??', '01', $date);

        return \DateTimeImmutable::createFromFormat('!m-d-y', $date, new \DateTimeZone('UTC')) ?: null;
    }
538033
protected function getDateTimeInstance(string $time = "now", \DateTimeZone $timezone = null): DateTime
    {
        $result = new self::$_dateTimeClassName($time, $timezone);

        return $result;
    }
729921
public function convertTimestamp($date, $format)
    {
        if (! is_numeric($date)) {
            $date = strtotime($date);
        }
        
        return $this->getDt()
            ->createFromTimestamp($date, $this->getTz())
            ->format($format);
    }