Ensure int never makes it to DateTime object.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user