Skip to content

Commit 828585a

Browse files
committed
DateTime: refactoring
1 parent f3292e7 commit 828585a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/Utils/DateTime.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DateTime extends \DateTime implements \JsonSerializable
4545
public static function from(string|int|\DateTimeInterface|null $time): static
4646
{
4747
if ($time instanceof \DateTimeInterface) {
48-
return new static($time->format('Y-m-d H:i:s.u'), $time->getTimezone());
48+
return static::createFromInterface($time);
4949

5050
} elseif (is_numeric($time)) {
5151
if ($time <= self::YEAR) {
@@ -96,10 +96,7 @@ public static function createFromFormat(
9696
string|\DateTimeZone|null $timezone = null,
9797
): static|false
9898
{
99-
if ($timezone === null) {
100-
$timezone = new \DateTimeZone(date_default_timezone_get());
101-
102-
} elseif (is_string($timezone)) {
99+
if (is_string($timezone)) {
103100
$timezone = new \DateTimeZone($timezone);
104101
}
105102

0 commit comments

Comments
 (0)