From 0b1547818d187b97dc9e9c79faaa28f439342c57 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 24 Jan 2011 20:47:35 +0100 Subject: [PATCH] DibiDateTime::__construct accepts unix timestamp --- dibi/libs/DibiDateTime.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dibi/libs/DibiDateTime.php b/dibi/libs/DibiDateTime.php index 9999803e..a502cfa0 100644 --- a/dibi/libs/DibiDateTime.php +++ b/dibi/libs/DibiDateTime.php @@ -20,6 +20,20 @@ class DibiDateTime extends DateTime { + public function __construct($time = 'now', DateTimeZone $timezone = NULL) + { + if (is_numeric($time)) { + $time = date('Y-m-d H:i:s', $time); + } + if ($timezone === NULL) { + parent::__construct($time); + } else { + parent::__construct($time, $timezone); + } + } + + + public function __sleep() { $this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());