<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CmsBundle\Components;

use Ferienpass\CoreBundle\Entity\OfferDate;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent(template: '@Contao/components/offer_date_single.html.twig')]
class OfferDateSingle
{
    public ?\DateTimeInterface $begin = null;
    public ?\DateTimeInterface $end = null;
    public bool $noTime = false;
    public ?string $locale = null;

    public function mount(?OfferDate $date = null, ?\DateTimeInterface $begin = null, ?\DateTimeInterface $end = null): void
    {
        if ($date) {
            $this->begin = $date->getBegin();
            $this->end = $date->getEnd();
        } elseif ($begin && $end) {
            $this->begin = $begin;
            $this->end = $end;
        }
    }
}
