mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 21:58:10 +02:00
DibiDateTime: fixed unknown timezone error when serialized date includes the timezone (i. e. 'Y-m-d H:i:sP') [Closes #107]
This commit is contained in:
@@ -48,14 +48,23 @@ class DibiDateTime extends DateTime
|
|||||||
|
|
||||||
public function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
$this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());
|
$zone = $this->getTimezone()->getName();
|
||||||
|
if ($zone[0] === '+') {
|
||||||
|
$this->fix = array($this->format('Y-m-d H:i:sP'));
|
||||||
|
} else {
|
||||||
|
$this->fix = array($this->format('Y-m-d H:i:s'), $zone);
|
||||||
|
}
|
||||||
return array('fix');
|
return array('fix');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __wakeup()
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
|
if (isset($this->fix[1])) {
|
||||||
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
|
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
|
||||||
|
} else {
|
||||||
|
$this->__construct($this->fix[0]);
|
||||||
|
}
|
||||||
unset($this->fix);
|
unset($this->fix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user