Ensure int never makes it to DateTime object.

This commit is contained in:
abdulmohsen
2024-04-28 19:18:49 +03:00
parent febb40a151
commit 9059adcb6e

View File

@@ -6,12 +6,22 @@ namespace App\Libs\Extends;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use JsonSerializable;
use Stringable;
final class Date extends DateTimeImmutable implements Stringable, JsonSerializable
{
public const ATOM = DateTimeInterface::ATOM;
public const string ATOM = DateTimeInterface::ATOM;
public function __construct(string|int $time = 'now', ?DateTimeZone $timezone = null)
{
if (ctype_digit($time)) {
$time = '@' . $time;
}
parent::__construct($time, $timezone);
}
public function __toString(): string
{