CoreFiles by mySites.guru
SystemClock.php32 lines, 655 bytes, from Joomla_6.2.0-rc2-Release_Candidate-Full_Package.zip
Raw History Compare with 6.2.0-rc1
md5
e1d67251441bd44c26b6143b46950f24
sha1
46ccc551b7dc513bba3c44373a9f6e11aa496450
sha256
c407ff5119cffa9cd1a545be888c759649bf44920327a7f4d88e5ddd8c0e0828
<?php
declare(strict_types=1);

namespace Lcobucci\Clock;

use DateTimeImmutable;
use DateTimeZone;

use function date_default_timezone_get;

/** @immutable */
final readonly class SystemClock implements Clock
{
    public function __construct(private DateTimeZone $timezone)
    {
    }

    public static function fromUTC(): self
    {
        return new self(new DateTimeZone('UTC'));
    }

    public static function fromSystemTimezone(): self
    {
        return new self(new DateTimeZone(date_default_timezone_get()));
    }

    public function now(): DateTimeImmutable
    {
        return new DateTimeImmutable('now', $this->timezone);
    }
}

The same content is in 32 releases, Joomla 6.1.0-alpha2 to 6.3.0-alpha1. See them all, or every version of this file.