mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-08 17:34:32 +02:00
Use DatetimeImmutable instead of DateTime wherever possible
This commit is contained in:
parent
eebc373734
commit
235d572f8c
39 changed files with 222 additions and 112 deletions
|
@ -105,13 +105,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
protected string $comment = '';
|
||||
|
||||
/**
|
||||
* @var \DateTime|null Set a time until when the lot must be used.
|
||||
* @var \DateTimeImmutable|null Set a time until when the lot must be used.
|
||||
* Set to null, if the lot can be used indefinitely.
|
||||
*/
|
||||
#[Groups(['extended', 'full', 'import', 'part_lot:read', 'part_lot:write'])]
|
||||
#[ORM\Column(name: 'expiration_date', type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
#[ORM\Column(name: 'expiration_date', type: Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||
#[Year2038BugWorkaround]
|
||||
protected ?\DateTime $expiration_date = null;
|
||||
protected ?\DateTimeImmutable $expiration_date = null;
|
||||
|
||||
/**
|
||||
* @var StorageLocation|null The storelocation of this lot
|
||||
|
@ -194,7 +194,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
}
|
||||
|
||||
//Check if the expiration date is bigger then current time
|
||||
return $this->expiration_date < new DateTime('now');
|
||||
return $this->expiration_date < new \DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,7 +236,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
/**
|
||||
* Gets the expiration date for the part lot. Returns null, if no expiration date was set.
|
||||
*/
|
||||
public function getExpirationDate(): ?\DateTimeInterface
|
||||
public function getExpirationDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->expiration_date;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
*
|
||||
*
|
||||
*/
|
||||
public function setExpirationDate(?\DateTime $expiration_date): self
|
||||
public function setExpirationDate(?\DateTimeImmutable $expiration_date): self
|
||||
{
|
||||
$this->expiration_date = $expiration_date;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue