@static
@access public
@param  \DateTime $birthday
@return Date

@throws \InvalidArgumentException
@throws \OutOfRangeException
@throws \DomainException
@throws \LengthException
511885
public static function fromDateTime(\DateTime $birthday)
    {
        $date = clone $birthday;

        return new self(
            new Year($date->format('Y')),
            new Month($date->format('m')),
            new Day($date->format('d'))
        );
    }
441936
private static function buildDateTime($dateTime, $startOfDay = false, $endOfDay = false)
    {
        $dateTime = new Carbon($dateTime);

        if ($startOfDay) {
            $dateTime = $dateTime->startOfDay();
        }

        if ($endOfDay) {
            $dateTime = $dateTime->endOfDay();
        }

        return (string) $dateTime;
    }
641113
public function setDate(\DateTime $dateTime)
    {
        $this->set(Config::T540, $dateTime->format('Ymd'));

        return $this;
    }
1347058
public static function fromDateTime(DateTime $date)
    {
        $workday = new static("@" . $date->getTimestamp());
        $workday->setTimezone($date->getTimezone());

        return $workday;
    }
291822
public static function convertToDbDate(\DateTime $dateTime) {
		
		$currentTz = $dateTime->getTimezone();
		$dateTime->setTimezone(new \DateTimeZone(BASE_TIMEZONE));
		$ret = $dateTime->format('Y-m-d');
		$dateTime->setTimezone($currentTz);
		return $ret;
		
	}
1300624
private function _processDateTime($dateTime)
    {
        if (is_numeric($dateTime)) {
            $timestamp = $dateTime;
            $dateTime = new \DateTime();
            $dateTime->setTimestamp($timestamp);
        } elseif (empty($dateTime)) {
            throw new \InvalidArgumentException('Date/time is empty');
        } elseif (is_string($dateTime)) {
            $dateTime = new \DateTime($dateTime);
        }

        if (!($dateTime instanceof \DateTime)) {
            throw new \InvalidArgumentException('Incorrect date/time type');
        }
        return $dateTime;
    }
138276
public function setBirthdate($date)
    {
        if ($date instanceof DateTime) {
            $date = $date->format('Y-m-d');
        }

        $this->data->birthDate = $date;

        return $this;
    }
853006
static function parserDateTime($dateTime)
    {
        if (!$dateTime instanceof \DateTime) $dateTime = static::createDateTimeClass($dateTime);
        $year = $dateTime->format('Y');
        $day = $dateTime->format('j');
        $month = $dateTime->format('n');
        $hour = $dateTime->format('H');
        $minute = $dateTime->format('i');
        $second = $dateTime->format('s');
        return [ $hour, $minute, $second, $month, $day, $year ];
    }
1160537
public function setBirthDate($value)
    {
        if (!preg_match($this->getBirthDateValidationRegex(), $value) || strtotime($value) === false) {
            throw new ErrorParameter('Birth date has to be in format dd-mm-yyyy.');
        }

        $this->birth_date = $value;

        return $this;
    }
657364
public function setDateBirth($date_birth){
        if(!$this->setModified('date_birth', $date_birth)->isModified()){
            return $this;
        }
        $this->date_birth = $date_birth;

        return $this;
    }
1225469
public function setThaiYear(DateTime $timestamp){
        if($this->checkThaiLocale()){
            return $timestamp->setDate(($timestamp->format('Y')+543),$timestamp->format('m'),$timestamp->format('d'));
        }else{
            return $timestamp;
        }
    }
682656
public static function FromDateTime( \DateTime $dt ) : DateTime
   {

      if ( $dt instanceof DateTime )
      {
         return clone $dt;
      }

      return new DateTime( $dt->format('Y-m-d H:i:s.u'), $dt->getTimezone() );

   }
424285
public function withExpires(DateTime $datetime)
    {
        $datetime->setTimezone(new DateTimeZone('UTC'));

        return $this->withHeader('Expires', $datetime->format('D, d M Y H:i:s') . ' GMT');
    }
494405
public static function fromNative(DateTimeInterface $dateTime): Date
    {
        $year = (int) $dateTime->format('Y');
        $month = (int) $dateTime->format('n');
        $day = (int) $dateTime->format('j');

        return new static($year, $month, $day);
    }
298787
public static function getDateTime($datetime = null)
    {
        if ($datetime instanceof \DateTime) {
            return clone $datetime;
        }
        if ($datetime instanceof \DateTimeImmutable) {
            return new \DateTime($datetime->format(\DateTime::ATOM));
        }
        if (\is_string($datetime)) {
            if (\is_numeric($datetime)) {
                /*
                    check if datetime is an int of the the form YYYYMMDD or YYYYMMDDHHMMSS
                    Debug::_log('datetime', $datetime)
                */
                $isTs = !preg_match('/^(19|20)\d{2}(0[1-9]|1[0-2])[0-3][0-9](([01]\d|2[0-3])\d[0-5]\d[0-5]\d)?$/', $datetime);
                if ($isTs) {
                    $datetime = '@'.$datetime;
                }
            }
            Debug::_log('datetime', $datetime);
            return new \DateTime($datetime);
        }
        if (\is_int($datetime) || \is_float($datetime)) {
            $dateTime = new \DateTime();
            $dateTime->setTimestamp($datetime);
            return $dateTime;
        }
        return new \DateTime();
    }
449248
protected static function dateFormatter($dateTime, $format)
    {
        if (is_numeric($dateTime)) {
            return gmdate($format, (int) $dateTime);
        }

        if (is_string($dateTime)) {
            $dateTime = new \DateTime($dateTime);
        }

        if ($dateTime instanceof \DateTime) {
            return $dateTime->setTimezone(self::getUtcTimeZone())->format($format);
        }

        throw new InvalidArgumentException('Date/Time values must be either a string, integer, or DateTime object');
    }
68409
public function calcAge(DateTime $birthDate, DateTime $refDate = null) {
        return DateTimeRenderer::renderAge($birthDate, $refDate);
    }