add test for timezone in instance from DateTime object

temporary fix for php 8.1 warning
This commit is contained in:
Mahdi Ziraki committed 2022-02-23 21:10:32 +03:30
1 parent 84b7bf87a1
commit 4db4b98065
3 files changed
+22 -6

No files matched your search

+7 -4
View File
@@ -31,10 +31,11 @@ trait Creator
}
try {
$tz = static::createTimeZone($timezone);
parent::__construct($dt, $tz);
if ($datetime instanceof DateTime) {
parent::setTimezone($tz);
parent::__construct($dt);
parent::setTimezone($datetime->getTimezone());
} else {
parent::__construct($dt, static::createTimeZone($timezone));
}
self::loadMessages();
} catch (Exception $exception) {
@@ -130,7 +131,9 @@ trait Creator
*/
public function datetime()
{
return new DateTime(date('Y-m-d H:i:s', $this->getTimestamp()), $this->getTimezone());
$dt = new DateTime(date('Y-m-d H:i:s', $this->getTimestamp()));
$dt->setTimezone($this->getTimezone());
return $dt;
}
/**