From 8fcb783abab541b33476550a1acd1a7ae5c9b711 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Fri, 7 May 2010 13:34:01 +0200 Subject: [PATCH] Fix UFC_Death (didn't work with dates before the epoch...) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- classes/userfilter.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/classes/userfilter.php b/classes/userfilter.php index f9a5202..f95feb9 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -406,7 +406,7 @@ class UFC_Nationality implements UserFilterCondition // {{{ class UFC_Dead /** Filters users based on death date * @param $comparison Comparison operator - * @param $date Date to which death date should be compared + * @param $date Date to which death date should be compared (DateTime object, string or timestamp) */ class UFC_Dead implements UserFilterCondition { @@ -416,7 +416,13 @@ class UFC_Dead implements UserFilterCondition public function __construct($comparison = null, $date = null) { $this->comparison = $comparison; - $this->date = $date; + if ($date instanceof DateTime) { + $this->date = $date; + } else if (is_int($date)) { + $this->date = new DateTime("@$date"); + } else { + $this->date = new DateTime($date); + } } public function buildCondition(PlFilter &$uf) @@ -424,7 +430,7 @@ class UFC_Dead implements UserFilterCondition $uf->requireProfiles(); $str = 'p.deathdate IS NOT NULL'; if (!is_null($this->comparison)) { - $str .= ' AND p.deathdate ' . $this->comparison . ' ' . XDB::format('{?}', date('Y-m-d', $this->date)); + $str .= ' AND p.deathdate ' . $this->comparison . ' ' . XDB::format('{?}', $this->date->format('Y-m-d')); } return $str; } -- 2.1.4