123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace Symfony\Component\Mime\Header;
- final class DateHeader extends AbstractHeader
- {
- private $dateTime;
- public function __construct(string $name, \DateTimeInterface $date)
- {
- parent::__construct($name);
- $this->setDateTime($date);
- }
-
- public function setBody($body)
- {
- $this->setDateTime($body);
- }
- public function getBody(): \DateTimeImmutable
- {
- return $this->getDateTime();
- }
- public function getDateTime(): \DateTimeImmutable
- {
- return $this->dateTime;
- }
-
- public function setDateTime(\DateTimeInterface $dateTime)
- {
- if ($dateTime instanceof \DateTime) {
- $immutable = new \DateTimeImmutable('@'.$dateTime->getTimestamp());
- $dateTime = $immutable->setTimezone($dateTime->getTimezone());
- }
- $this->dateTime = $dateTime;
- }
- public function getBodyAsString(): string
- {
- return $this->dateTime->format(\DateTime::RFC2822);
- }
- }
|