aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2014-09-08 12:35:08 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2014-09-08 12:35:08 +0200
commit76b32038c6eea62257955992959588a3d36fd7b7 (patch)
treeb8e815c46ceb4c5640fa86655ad6459a9915bfe9
parentBug 768892 - Specific Search without search words yields invalid_column_name ... (diff)
downloadbugzilla-76b32038c6eea62257955992959588a3d36fd7b7.tar.gz
bugzilla-76b32038c6eea62257955992959588a3d36fd7b7.tar.bz2
bugzilla-76b32038c6eea62257955992959588a3d36fd7b7.zip
Bug 1046213: datetime_from() generates wrong dates if year < 1901
r=sgreen a=glob
-rw-r--r--Bugzilla/Util.pm10
1 files changed, 7 insertions, 3 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 164ff40bf..4bd10e16c 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -569,10 +569,14 @@ sub datetime_from {
return undef if !@time;
- # strptime() counts years from 1900, and months from 0 (January).
- # We have to fix both values.
+ # strptime() counts years from 1900, except if they are older than 1901
+ # in which case it returns the full year (so 1890 -> 1890, but 1984 -> 84,
+ # and 3790 -> 1890). We make a guess and assume that 1100 <= year < 3000.
+ $time[5] += 1900 if $time[5] < 1100;
+
my %args = (
- year => $time[5] + 1900,
+ year => $time[5],
+ # Months start from 0 (January).
month => $time[4] + 1,
day => $time[3],
hour => $time[2],