Skip to content

Commit

Permalink
Add datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
maillotf committed Oct 28, 2020
1 parent 4f9bd74 commit bf6b2f6
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/Objects/WeekSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,42 @@ class WeekSchedule extends AbstractArdObject
* @var int
*/
private $creationdate;

/**
*
* @var \DateTime
*/
private $creationdatetime = null;

/**
*
* @var int
*/
private $modificationdate;

/**
*
* @var \DateTime
*/
private $modificationdatetime = null;

/**
*
* @var DateTimeZone
*/
private $datetimezone;

public function init()
{
parent::init();
$this->setDatetimezone('Europe/Paris');
}

public function __construct($datetimezone = 'Europe/Paris')
{
$this->datetimezone = new \DateTimeZone($datetimezone);
}

public function setUid(int $uid): WeekSchedule
{
$this->uid = $uid;
Expand Down Expand Up @@ -84,6 +113,17 @@ public function getCreationdate(): int
return $this->creationdate;
}

public function getCreationdatetime(): ?\DateTime
{
if ($this->creationdatetime == null)
{
$this->creationdatetime = new \DateTime();
$this->creationdatetime->setTimezone($this->datetimezone);
$this->creationdatetime->setTimestamp($this->getCreationdate());
}
return ($this->creationdatetime);
}

public function setModificationdate(int $modificationdate): WeekSchedule
{
$this->modificationdate = $modificationdate;
Expand All @@ -94,5 +134,26 @@ public function getModificationdate(): int
{
return $this->modificationdate;
}

public function getModificationdatetime(): ?\DateTime
{
if ($this->modificationdatetime == null)
{
$this->modificationdatetime = new \DateTime();
$this->modificationdatetime->setTimezone($this->datetimezone);
$this->modificationdatetime->setTimestamp($this->getModificationdate());
}
return ($this->modificationdatetime);
}

public function setDatetimezone(string $datetimezone)
{
$this->datetimezone = new \DateTimeZone($datetimezone);
return ($this);
}

public function getDatetimezone(): \DateTimeZone
{
return ($this->datetimezone);
}
}

0 comments on commit bf6b2f6

Please sign in to comment.