Extract a Date class for event dates
This commit is contained in:
parent
c2dd8a1a07
commit
c2cd2164f5
3 changed files with 27 additions and 5 deletions
20
modules/opd_presentations/src/Date.php
Normal file
20
modules/opd_presentations/src/Date.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_presentations;
|
||||
|
||||
readonly final class Date {
|
||||
|
||||
public function toTimestamp(): int {
|
||||
return $this->date->getTimestamp();
|
||||
}
|
||||
|
||||
public static function fromString(string $date): self {
|
||||
return new self(new \DateTimeImmutable($date));
|
||||
}
|
||||
|
||||
private function __construct(private \DateTimeImmutable $date) {
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue