summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-07-11 08:19:59 +0200
committerlpsolit%gmail.com <>2005-07-11 08:19:59 +0200
commit9a46dc023dc2123c305f2b7bc39ddc5efb7c9c6e (patch)
treec185c1f1db410f194da092629a787fbee2fb02ae /Bugzilla/Search.pm
parentdf8ee685cf1f6ad78f3a4c0d01d64cc492c5c19d (diff)
downloadbugzilla-9a46dc023dc2123c305f2b7bc39ddc5efb7c9c6e.tar.gz
bugzilla-9a46dc023dc2123c305f2b7bc39ddc5efb7c9c6e.tar.xz
Bug 291209: Allow Relative Date Searches by Hour - Patch by Justin "Callek" Wood <bugspam.Callek@gmail.com> r=joel a=justdave
Diffstat (limited to 'Bugzilla/Search.pm')
-rw-r--r--Bugzilla/Search.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index ec93e96a8..8e43353a3 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -1409,7 +1409,7 @@ sub SqlifyDate {
}
- if ($str =~ /^(-|\+)?(\d+)([dDwWmMyY])$/) { # relative date
+ if ($str =~ /^(-|\+)?(\d+)([hHdDwWmMyY])$/) { # relative date
my ($sign, $amount, $unit, $date) = ($1, $2, lc $3, time);
my ($sec, $min, $hour, $mday, $month, $year, $wday) = localtime($date);
if ($sign eq '+') { $amount = -$amount; }
@@ -1429,6 +1429,15 @@ sub SqlifyDate {
while ($month<0) { $year--; $month += 12; }
return sprintf("%4d-%02d-01 00:00:00", $year+1900, $month+1);
}
+ elsif ($unit eq 'h') {
+ # Special case 0h for 'beginning of this hour'
+ if ($amount == 0) {
+ $date -= $sec + 60*$min;
+ } else {
+ $date -= 3600*$amount;
+ }
+ return time2str("%Y-%m-%d %H:%M:%S", $date);
+ }
return undef; # should not happen due to regexp at top
}
my $date = str2time($str);