[bugzilla-gnome-org-upstream/4.4] Bug 1112181: Relative dates in the future involving months are incorrectly converted r=dylan a=glob



commit 24b471d6edd1e124dbaf860cf6ce2beada20359a
Author: Frédéric Buclin <LpSolit gmail com>
Date:   Tue Feb 17 21:30:05 2015 +0100

    Bug 1112181: Relative dates in the future involving months are incorrectly converted
    r=dylan a=glob

 Bugzilla/Search.pm |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index eaab600..acf458e 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -31,7 +31,7 @@ use Date::Format;
 use Date::Parse;
 use Scalar::Util qw(blessed);
 use List::MoreUtils qw(all firstidx part uniq);
-use POSIX qw(INT_MAX);
+use POSIX qw(INT_MAX floor);
 use Storable qw(dclone);
 use Time::HiRes qw(gettimeofday tv_interval);
 
@@ -2129,7 +2129,8 @@ sub SqlifyDate {
         }
         elsif ($unit eq 'm') {
             $month -= $amount;
-            while ($month<0) { $year--; $month += 12; }
+            $year += floor($month/12);
+            $month %= 12;
             if ($startof) {
                 return sprintf("%4d-%02d-01 00:00:00", $year+1900, $month+1);
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]