From: Frédéric Buclin Date: Thu, 12 Apr 2012 18:44:59 +0000 (+0200) Subject: Bug 737436: Relative dates do not work correctly with the deadline field X-Git-Tag: bugzilla-4.2.1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8169d04e9c85cde59e030bfb665f5e1c065e9c1a;p=thirdparty%2Fbugzilla.git Bug 737436: Relative dates do not work correctly with the deadline field r=dkl a=LpSolit --- diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 03242ae83f..2ea4b1ae13 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1924,16 +1924,22 @@ sub _timestamp_translate { my $value = $args->{value}; my $dbh = Bugzilla->dbh; - return if $value !~ /^[\+\-]?\d+[hdwmy]s?$/i; - - $args->{value} = SqlifyDate($value); - $args->{quoted} = $dbh->quote($args->{value}); + return if $value !~ /^(?:[\+\-]?\d+[hdwmy]s?|now)$/i; + + # By default, the time is appended to the date, which we don't want + # for deadlines. + $value = SqlifyDate($value); + if ($args->{field} eq 'deadline') { + ($value) = split(/\s/, $value); + } + $args->{value} = $value; + $args->{quoted} = $dbh->quote($value); } sub SqlifyDate { my ($str) = @_; my $fmt = "%Y-%m-%d %H:%M:%S"; - $str = "" if !defined $str; + $str = "" if (!defined $str || lc($str) eq 'now'); if ($str eq "") { my ($sec, $min, $hour, $mday, $month, $year, $wday) = localtime(time()); return sprintf("%4d-%02d-%02d 00:00:00", $year+1900, $month+1, $mday);