From 9244a1b1b502c8ef1bebd21213a3596fc0395454 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 25 Nov 2008 20:33:52 +0000 Subject: [PATCH] - supported UNIX timestamp in datetime column --- dibi/dibi.php | 6 +++--- dibi/libs/DibiResult.php | 2 +- dibi/libs/DibiTranslator.php | 2 +- examples/sample.mdb | Bin 274432 -> 290816 bytes examples/sample.sdb | Bin 6144 -> 5120 bytes 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dibi/dibi.php b/dibi/dibi.php index 5db46c2e..a5301218 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -527,10 +527,10 @@ class dibi { if ($time === NULL) { $time = time(); // current time - } elseif (is_string($time)) { - $time = strtotime($time); // try convert to timestamp + } elseif (is_numeric($time)) { + $time = (int) $time; // timestamp } else { - $time = (int) $time; + $time = strtotime($time); // try convert to timestamp } return new DibiVariable($time, dibi::FIELD_DATETIME); } diff --git a/dibi/libs/DibiResult.php b/dibi/libs/DibiResult.php index 213dc63e..ba96332a 100644 --- a/dibi/libs/DibiResult.php +++ b/dibi/libs/DibiResult.php @@ -503,7 +503,7 @@ class DibiResult extends DibiObject implements IDataSource case dibi::FIELD_DATE: case dibi::FIELD_DATETIME: - $value = strtotime($value); + $value = is_numeric($value) ? (int) $value : strtotime($value); return $format === NULL ? $value : date($format, $value); case dibi::FIELD_BOOL: diff --git a/dibi/libs/DibiTranslator.php b/dibi/libs/DibiTranslator.php index e7b4afa9..cbed9e17 100644 --- a/dibi/libs/DibiTranslator.php +++ b/dibi/libs/DibiTranslator.php @@ -307,7 +307,7 @@ final class DibiTranslator extends DibiObject case 'd': // date case 't': // datetime - return $this->driver->escape(is_string($value) ? strtotime($value) : $value, $modifier); + return $this->driver->escape(is_numeric($value) ? (int) $value : strtotime($value), $modifier); case 'by': case 'n': // identifier name diff --git a/examples/sample.mdb b/examples/sample.mdb index 1185a92ee1914e3625045f07e3b9407c80042369..e7730c28372859e0c3c8eb91495323875b60785e 100644 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