]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 291209: Allow Relative Date Searches by Hour - Patch by Justin "Callek" Wood...
authorlpsolit%gmail.com <>
Mon, 11 Jul 2005 06:19:59 +0000 (06:19 +0000)
committerlpsolit%gmail.com <>
Mon, 11 Jul 2005 06:19:59 +0000 (06:19 +0000)
Bugzilla/Search.pm
template/en/default/search/search-help.html.tmpl

index ec93e96a80b589768efe16d5b1b8a9fabd59be19..8e43353a3207ba151947b91a23ba23c625977682 100644 (file)
@@ -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);
index 0d4b53e267f981a8c63825586f69900237c45c3d..0c8529d05b5fbca87e97d9cda2d44197f329a65d 100644 (file)
 { id => "chfieldfrom", 
   html => "Specify the start and end dates either in YYYY-MM-DD format<br>
            (optionally followed by HH:mm, in 24 hour clock), or in relative<br>
-           dates such as 1d, 2w, 3m, 4y, which respectively mean one day,<br>
-           two weeks, three months, or four years ago. 0d is last midnight,<br>
-           and 0w, 0m, 0y is the beginning of this week, month, or year." },
+           dates such as 1h, 2d, 3w, 4m, 5y, which respectively mean one hour,<br>
+           one day, two weeks, three months, or four years ago. 0d is last<br>
+           midnight, and 0h, 0w, 0m, 0y is the beginning of this hour, week,<br>
+           month, or year." },
 { id => "chfieldto", 
   html => "Specify the start and end dates either in YYYY-MM-DD format<br>
            (optionally followed by HH:mm, in 24 hour clock), or in relative<br>
-           dates such as 1d, 2w, 3m, 4y, which respectively mean one day,<br>
-           two weeks, three months, or four years ago. 0d is last midnight,<br>
-           and 0w, 0m, 0y is the beginning of this week, month, or year." },
+           dates such as 1h, 2d, 3w, 4m, 5y, which respectively mean one hour,<br>
+           one day, two weeks, three months, or four years ago. 0d is last<br>
+           midnight, and 0h, 0w, 0m, 0y is the beginning of this hour, week,<br>
+           month, or year." },
 { id => "chfieldvalue", 
   html => "The value the field defined above changed to during that time." },   
 ] %]