1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-24 02:43:09 +01: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:
Rossler Jan 2013-09-30 01:09:14 +02:00 committed by David Grudl
parent a36678d3db
commit 30b5290c9d

View File

@ -48,14 +48,23 @@ class DibiDateTime extends DateTime
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');
}
public function __wakeup()
{
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
if (isset($this->fix[1])) {
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
} else {
$this->__construct($this->fix[0]);
}
unset($this->fix);
}