everything changed to datetime

This commit is contained in:
Julie Lenaerts 2021-08-10 10:56:45 +02:00
parent b74f9cf5dc
commit fb43980a2a
3 changed files with 13 additions and 12 deletions

View File

@ -35,9 +35,9 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac
private \Chill\MainBundle\Entity\User $createdBy;
/**
* @ORM\Column(type="datetime_immutable")
* @ORM\Column(type="datetime")
*/
private \DateTimeInterface $createdAt;
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
@ -45,9 +45,9 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac
private \Chill\MainBundle\Entity\User $updatedBy;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @ORM\Column(type="datetime", nullable=true)
*/
private \DateTimeInterface $updatedAt;
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
@ -57,14 +57,14 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac
private \Chill\MainBundle\Entity\User $agent;
/**
* @ORM\Column(type="datetime_immutable")
* @ORM\Column(type="datetime")
*/
private \DateTimeInterface $date;
private $date;
/**
* @ORM\Column(type="time", nullable=true)
*/
private ?\DateTime $duration = null;
private ?\DateTimeInterface $duration = null;
/**
* @ORM\Column(type="string", length=100, nullable=true)
@ -165,12 +165,12 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac
return $this;
}
public function getDuration(): ?\DateTime
public function getDuration(): ?\DateTimeInterface
{
return $this->duration;
}
public function setDuration(?\DateTime $duration): self
public function setDuration(?\DateTimeInterface $duration): self
{
$this->duration = $duration;

View File

@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Entity
* @ORM\Table(schema="chill_asideactivity")
*/
final class AsideActivityCategory
class AsideActivityCategory
{
/**
* @ORM\Id

View File

@ -55,7 +55,7 @@ final class AsideActivityFormType extends AbstractType
->add('date', ChillDateType::class,
[
'label' => 'date',
'data' => new \DateTimeImmutable(),
'data' => new \DateTime(),
//SETTING RANGE ONLY POSSIBLE WITH WIDGET 'CHOICE' AND NOT 'SINGLE_TEXT'?
// 'widget' => 'choice',
// 'years' => range(2020, date('Y')),
@ -96,13 +96,14 @@ final class AsideActivityFormType extends AbstractType
// set the timezone to GMT, and fix the difference between current and GMT
// the datetimetransformer will then handle timezone as GMT
$timezoneUTC = new \DateTimeZone('GMT');
/* @var $data \DateTime */
/* @var $data \DateTimeImmutable */
$data = $formEvent->getData() === NULL ?
\DateTime::createFromFormat('U', 300) :
$formEvent->getData();
$seconds = $data->getTimezone()->getOffset($data);
$data->setTimeZone($timezoneUTC);
$data->add(new \DateInterval('PT'.$seconds.'S'));
dump($data);
// test if the timestamp is in the choices.
// If not, recreate the field with the new timestamp