mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
DateTime53 renamed to DibiDateTime
This commit is contained in:
51
dibi/libs/DibiDateTime.php
Normal file
51
dibi/libs/DibiDateTime.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the "dibi" - smart database abstraction layer.
|
||||
*
|
||||
* Copyright (c) 2005, 2010 David Grudl (http://davidgrudl.com)
|
||||
*
|
||||
* This source file is subject to the "dibi license", and/or
|
||||
* GPL license. For more information please see http://dibiphp.com
|
||||
* @package dibi
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* DateTime with serialization and timestamp support for PHP 5.2.
|
||||
*
|
||||
* @author David Grudl
|
||||
*/
|
||||
class DibiDateTime extends DateTime
|
||||
{
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
$this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());
|
||||
return array('fix');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
|
||||
unset($this->fix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getTimestamp()
|
||||
{
|
||||
return (int) $this->format('U');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setTimestamp($timestamp)
|
||||
{
|
||||
return $this->__construct(date('Y-m-d H:i:s', $timestamp), new DateTimeZone($this->getTimezone()->getName())); // getTimeZone() crashes in PHP 5.2.6
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user