summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2014-09-10 10:38:28 +0200
committerByron Jones <glob@mozilla.com>2014-09-10 10:39:03 +0200
commit0626dcb56ab482ac4388e3aa676442c9a9993670 (patch)
tree05fce4e7d0e435d9413a0c5eb363b3e540878eb7 /Bugzilla
parentbb4c6f7122d30a48d0d80dcfd7a99e1d0be0ff38 (diff)
downloadbugzilla-0626dcb56ab482ac4388e3aa676442c9a9993670.tar.gz
bugzilla-0626dcb56ab482ac4388e3aa676442c9a9993670.tar.xz
Bug 1046213: datetime_from() generates wrong dates if year < 1901
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Util.pm10
1 files changed, 7 insertions, 3 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 27a7e5e23..6a89cf4fc 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -562,10 +562,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],