<?php
 namespace App\ImportedOrder; class DateTime extends EntityAbstract { public $dateStart; public $dateEnd; public $dateDetails; public $timeStart; public $timeEnd; public $timeDetails; protected function validateEntityFields(\App\MessagesCollector $messagesCollector): void { if ($this->dateStart and !validDate($this->dateStart)) { $messagesCollector->addInfo('The date start range is not valid.'); } if ($this->timeStart and !\Engine\Validator::set($this->timeStart)->isTime()) { $messagesCollector->addInfo('The time start range is not valid.'); } if ($this->dateEnd and !validDate($this->dateEnd)) { $messagesCollector->addInfo('The date end range is not valid.'); } if ($this->timeEnd and !\Engine\Validator::set($this->timeEnd)->isTime()) { $messagesCollector->addInfo('The time end range is not valid.'); } } public function importFromDateTime(\Engine\DateTime $dateTime) { if ($dateTime->isValid() and !$dateTime->isEmpty()) { $date = $dateTime->formatDateIso(); $time = $dateTime->formatTimeIso(); if ($date) { $this->dateStart = $date; $this->dateEnd = $date; } if ($time) { $this->timeStart = $time; $this->timeEnd = $time; } } } public function getMatchedDate() { if ($this->dateStart and $this->dateEnd) { if ($this->dateStart==$this->dateEnd) { $return = $this->dateStart; } else { $return = ''; } } elseif ($this->dateStart) { $return = $this->dateStart; } elseif ($this->dateEnd) { $return = $this->dateEnd; } else { $return = ''; } if (!validDate($return)) { $return = ''; } return $return; } public function getMatchedTime() { if ($this->timeStart and $this->timeEnd) { if ($this->timeStart==$this->timeEnd) { $return = $this->timeStart; } else { $return = ''; } } elseif ($this->timeStart) { $return = $this->timeStart; } elseif ($this->timeEnd) { $return = $this->timeEnd; } else { $return = ''; } if (!\Engine\Validator::set($return)->isTime()) { $return = ''; } return $return; } } 