Extract a Date class for event dates

This commit is contained in:
Oliver Davies 2025-06-12 23:27:58 +01:00
parent c2dd8a1a07
commit c2cd2164f5
3 changed files with 27 additions and 5 deletions

View 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) {
}
}